About Insert Null to DateTime Field

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)
 
M

Mark Fitzpatrick

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
 
F

FatboyCanteen

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.
 
P

Prashant Kondle

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
 
F

FatboyCanteen

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

Thank YOu
 
P

Prashant Kondle

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

-PK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top