Re: problems inserting into sql using SqlHelper.ExecuteScalar
From: Hermit Dave (hermitd.REMOVE_at_CAPS.AND.DOTS.hotmail.com)
Date: 09/15/04
- Next message: Matt Berther: "Re: How to capture an XML HTTP Post in ASP.NET?"
- Previous message: Matt Berther: "Re: No button click event"
- In reply to: Chad Dittmer via .NET 247: "problems inserting into sql using SqlHelper.ExecuteScalar"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Sep 2004 19:57:00 +0100
please specify the length of varchars in your stored procedure
some thing like (the length of varchar should be less than or equal to
length of the column) i usually prefer equal - (dont see a reason why not)
CREATE PROCEDURE ProcContactsInsert
@CustID int,
@Cont1FirstName nvarchar(25),
@Cont1LastName nvarchar(25),
@Cont1Phone nvarchar(10),
@Cont1PhoneExt nvarchar(4),
@Cont1Fax nvarchar(10),
@Title nvarchar(3),
@Email nvarchar(100),
@Presort bit,
@PresortMeter bit,
@LetterShop bit,
@Printing bit,
@CellPhone nvarchar(10)
AS
INSERT INTO Contacts (CustID, Cont1FirstName, Cont1LastName, Cont1Phone,
Cont1PhoneExt, Cont1Fax, Title, Email, Presort, PresortMeter, LetterShop,
Printing, CellPhone)
VALUES (@CustID, @Cont1FirstName, @Cont1LastName, @Cont1Phone,
@Cont1PhoneExt, @Cont1Fax, @Title, @Email, @Presort, @PresortMeter,
@LetterShop, @Printing, @CellPhone)
SELECT CAST(scope_identity() AS INTEGER)
RETURN
GO
-- Regards, Hermit Dave (http://hdave.blogspot.com) "Chad Dittmer via .NET 247" <anonymous@dotnet247.com> wrote in message news:e#KjjQ1mEHA.2616@tk2msftngp13.phx.gbl... > I'm having problems inserting into Sql 2000 using SqlHelper.ExecuteScalar. > When it inserts, it only takes the first character from the string?? Any help would be appreciated. Here is the code and the stored procedure I'm using. > > Dim newRowId As Integer > newRowId = Convert.ToInt32(SqlHelper.ExecuteScalar(ConfigurationSettings.AppSettings("C onnectionString"), "ProcContactsInsert", 1234, "hparameter2", "parameter2", "tparamer2", "pareter2", "ypameter2", "parTitle", "parater2", 1, 0, 1, 0, "parameer2")) > > --------------------- > > CREATE PROCEDURE ProcContactsInsert > @CustID int, > @Cont1FirstName nvarchar, > @Cont1LastName nvarchar, > @Cont1Phone nvarchar, > @Cont1PhoneExt nvarchar, > @Cont1Fax nvarchar, > @Title nvarchar, > @Email nvarchar, > @Presort bit, > @PresortMeter bit, > @LetterShop bit, > @Printing bit, > @CellPhone nvarchar > AS > INSERT INTO Contacts (CustID, Cont1FirstName, Cont1LastName, Cont1Phone, Cont1PhoneExt, Cont1Fax, Title, Email, Presort, PresortMeter, LetterShop, Printing, CellPhone) > VALUES (@CustID, @Cont1FirstName, @Cont1LastName, @Cont1Phone, @Cont1PhoneExt, @Cont1Fax, @Title, @Email, @Presort, @PresortMeter, @LetterShop, @Printing, @CellPhone) > SELECT CAST(scope_identity() AS INTEGER) > RETURN > GO > > ------ > It returns the correct id number but the varchar fields are only recieving the first character of the values. > > ----------------------- > Posted by a user from .NET 247 (http://www.dotnet247.com/) > > <Id>BV3JhSpJ+0WMFtGSqpPgGg==</Id>
- Next message: Matt Berther: "Re: How to capture an XML HTTP Post in ASP.NET?"
- Previous message: Matt Berther: "Re: No button click event"
- In reply to: Chad Dittmer via .NET 247: "problems inserting into sql using SqlHelper.ExecuteScalar"
- Messages sorted by: [ date ] [ thread ]