VS05
How are dates removed / nullified?
I have a SQL datetime field that is being editted via a datatable / adapter - The table structure defines the datetime as a date.
From here I want to remove the date - i.e. write DBNull back to the database. Setting the Date to Nothing or .minvalue results in a min date exception and DBNull cannot be cast to the datetime either.
R
um...i dont have problem to have null in date type field.
do you set allow null to true in table schema?
|||
aye, the db field is set to allow nulls.. I can set the date field to null be SQL server them chucks it out saying its out of range - needs DBnull which the date type doesnt allow..
|||
RobC00:
aye, the db field is set to allow nulls.. I can set the date field to null be SQL server them chucks it out saying its out of range - needs DBnull which the date type doesnt allow..
To write Null Value into the database use the code in the link below by passing the Null value with IF/ELSE block to the Static method DateTime.Parse. Hope this helps.
http://www.c-sharpcorner.com/Code/2003/Sept/EnterNullValuesForDateTime.asp
No comments:
Post a Comment