S
Simon Harvey
Hi everyone,
I'm having a really simple problem - I can't seem to insert a null value
into the database. When I do it tells me that the procedure expects the parameter
and that I'm not providing it.
Well, I am, its just a null value!
The code is:
con.Open();
trans = con.BeginTransaction();
cmd = new SqlCommand("UpdateProperty", con, trans);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@id", id));
cmd.Parameters.Add(new SqlParameter("@propertyName", propertyName));
cmd.Parameters.Add(new SqlParameter("@city", null));
// THE PROBLEM
cmd.ExecuteNonQuery();
When executing the command, it throws an exception that says that the procedure
expects the @city parameter.
Can anyone tell me how to send the database a null value! The column definition
in the database is more than happy to take nulls
Thanks to anyone who can help
Kindest Regards
Simo
I'm having a really simple problem - I can't seem to insert a null value
into the database. When I do it tells me that the procedure expects the parameter
and that I'm not providing it.
Well, I am, its just a null value!
The code is:
con.Open();
trans = con.BeginTransaction();
cmd = new SqlCommand("UpdateProperty", con, trans);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@id", id));
cmd.Parameters.Add(new SqlParameter("@propertyName", propertyName));
cmd.Parameters.Add(new SqlParameter("@city", null));
// THE PROBLEM
cmd.ExecuteNonQuery();
When executing the command, it throws an exception that says that the procedure
expects the @city parameter.
Can anyone tell me how to send the database a null value! The column definition
in the database is more than happy to take nulls
Thanks to anyone who can help
Kindest Regards
Simo