I am creating / updating a record in sql db with a stored procedure. I supply about 30 parameters from my C # data access level. The sql table has all columns with a null value different from the primary key column. here, when I put a null value in a column with a null value, it throws an exception from the "Procedure or function" spFullUpdate 'expects the parameter' @ App1TAPAYears', which was not specified. ". In my C # code, I clearly see that the column is set to zero. Can someone tell me how I can fix this problem. Below is a snippet of code. The parameter value for the data object is as follows:
Dt.TimeAtPreviousAddressYears = int.TryParse(TimeatPreviousAddressYears.Text, out intOut) ? intOut : (int?)null;
the following nullable property in an entity class
public int? TimeAtPreviousAddressYears { get; set; }
My access code for data access settings is as follows:
cmd.Parameters.Add("@App1TAPAYears", SqlDbType.Int).Value = dataObject.TimeAtPreviousAddressYears; SqlDataAdapter da = new SqlDataAdapter(cmd); conn.Open(); cmd.ExecuteNonQuery();
You can clearly see that the parameter is added and the null value is passed to the column with the null value, but it still throws an exception. Any help would be really appreciated.
Good wishes
source share