I am having a column subdate as smalldatetime.
The field can have null values. But I am not able to insert null values into the database.
i tried using subdate="". But it inserts some min value of my calendar popup.
Is there a way that i could insert null values into smalldatetime field of the SQl database.
Thanks,
-sriramtry subdate=dbnull.value
hth|||Hi,
I tried subdate=dbnull.value
It still stores a date 1/1/1900.
I am not sure as whats the problem.
When i print the subdate it shows:'12:00:00 AM'.
Any suggestions?
thanks,
-sriram|||Are you sure it's stored as that? How are you reading it? Whatever way you're reading it might be converting it to a default date. Or it's not actually being stored as a null because of something happening as you write the value.
Don|||hi,
I am sure that the value is not stored as null.
I tried that many time.
It again stores the same value.
thanks,
-sriram|||Can you set the smalldatetime field's default value to null in the table designer, then simply omit that field when you insert a row to the table?
Hope this helps.
Thanks.|||Hi Siriam,
I set such fields to null all the time, so like I said before something is going wrong when you are setting the value or when you read it.
Please post the code you're using to set and read the value, and we'll try to figure out what's going on.
Don|||if printing the subdate produces '12:00:00 AM', it probably means your getting a zero back from the db, or you getting a NULL that is being converted into a zero in your code somehow.|||return (dbnull == dateTimeValue) ? System.DateTime.MinValue : dateTimeValue;|||Hi,
Thanks for helping. It works fine.
-sriram
No comments:
Post a Comment