Insert null values in MS SQL Sever 2000

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to insert a null value in a table on MS SQL Server 2000 using a stored
procedure.
When I send no data to the stored procedure, I get an error saying that the
value cannot be null, but I did the table to receive null values.
I tried DBNull.Value but didn't work.
Thanks, Rodrigo.
 
Do you have access to the Stored Procedure Code? Set a default value of
NULL on the Stored Procedure parameter; then when you want NULL inserted,
just don't pass that parameter to your SP. It will default to NULL and all
should be good.
 
Hi,

Why don't you try to run the query from Query Analizer and see what gives.

If still havin gproblem just post the code , the SP and the table definition
:)


cheers,
 
If you set the property "IsNullable" on your SqlParameter object to
true, then you should be fine.

Example:

SqlParameter myParam = new SqlParameter
( "@Description"
, sqlDataType.VarChar
);

myParam.IsNullable = true;
 
Back
Top