I have a datetime field in a database which I am programmatically inserting values into. The field can be null or not null. However, I am having problems inserting NULL as part of my SQLCommand.
The value is pulled from a text box (linked to a calendar extender) and when I select a value it is being inserted fine. If I just leave the box blank though, I want the field to be set to NULL. I have tried adding in ,DBNULL.Value, as part of my VALUES(…) string, but this throws an exception. I Have tried just inserting '' but that also throws an exception ("The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value"), so I don't know how I can insert this value when the field is blank?
Can anyone shed some light please?
Thanks
Check to see if the last answer of this other post helps:http://forums.asp.net/t/996855.aspx
|||You can also check if this post helps:http://dotnetjunkies.com/WebLog/dinakar/articles/74221.aspx
No comments:
Post a Comment