About Insert Null to DateTime Field

  • Thread starter Thread starter FatboyCanteen
  • Start date Start date
F

FatboyCanteen

When I using dataset to append
a null value to the datetime field.

It throw a error -> can not convert db.null to system.date

Can there is any standard to pass a Null value
to the DateTime Field!
(It is successful to pass the Null Value to other type of
Field)
 
You can pass nulls to other types, but not to a system.datetime. I instead
set it to system.datetime.minvalue and then test for that in my code as if
it was a null.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
Thank You for your reply!
Yes, I am using your method in the past (but using max
value)
However, I want to know anyone can successful insert a
null value to DateTime Field.
 
i use the following to insert NULL into datetime field and it works

Object.DateTimeField = DBNull.Value;

ofcourse the field should be able to accept null values...

-PK
 
Can you explain more detail about insert null value
Because I don't understand --
object.DateTimeField

Thank YOu
 
if ur using NullDate as the field containing the value to insert into the
DateTime field then
do
NullDate = DBNull.Value;

-PK
 
Back
Top