Click to See Complete Forum and Search --> : NULL DateTime with SQL SERVER


yosef
November 25th, 2006, 05:23 PM
Hello Codegurus

I write in C# and use SQL Server. Table in databse has field
of type 'datetime'. How I can to write (save) into this field NULL
value (date does not exists) and vise versa to read NULL value
and put it to DateTime object. Is the last supports NULL date values ?


Great Thanks

jp140768
December 5th, 2006, 07:39 PM
If you are using a stored procedure to update the table, you can set the field to Null, provided it allows Null values.

I code in VB, but in VB I would set the field to 'Null()' putting in the quotes, when sent to SQL Server, it would know that I wanted the field to contain a null value - don't know how to do this in C#

HTH

Krzemo
January 4th, 2007, 04:14 AM
Just send "System.Data.SqlTypes.SqlDateTime.Null" ....

Best regards,
Krzemo.