problems inserting into sql using SqlHelper.ExecuteScalar

  • Thread starter Thread starter Chad Dittmer via .NET 247
  • Start date Start date
C

Chad Dittmer via .NET 247

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("ConnectionString"), "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
 
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 said:
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
the first character of the values.
 
Back
Top