I have a stored procedure that uses several input parameters and insert them into Sql Database. There is a problem with one parameter, @CustomerId, that is truncated (but not always) when inserted into database.
C#:
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@CustomerId", Convert.ToInt32(customerId));
cmd.Connection = sqlConn;
sqlConn.Open();
cmd.ExecuteNonQuery();
sqlConn.Close();
Sql SP:
@CustomerId int
INSERT INTO dbo.tblOffers
(CustomerId)
VALUES
(@CustomerId)
sql table datatype:
CustomerId int not null
Example: 564276117 truncated to 4276117 (but its not happening all the time, and there are values greater than 560000000 that are inserted properly)
What am I doing wrong? Thanks
Try
Parameters.Add()method instead ofAddWithValue.