471,066 Members | 1,200 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

About Insert Null to DateTime Field

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)
Nov 17 '05 #1
6 16099
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

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in message
news:06****************************@phx.gbl...
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)

Nov 17 '05 #2
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.
-----Original Message-----
You can pass nulls to other types, but not to a system.datetime. I insteadset it to system.datetime.minvalue and then test for that in my code as ifit was a null.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in messagenews:06****************************@phx.gbl...
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)

.

Nov 17 '05 #3
Take a look @ http://www.c-sharpcorner.com/Code/20...orDateTime.asp

HTH
-Sushila

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in message news:07****************************@phx.gbl...
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.


-----Original Message-----
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

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in

message
news:06****************************@phx.gbl...
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)

.


Nov 17 '05 #4
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

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in message
news:06****************************@phx.gbl...
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)

Nov 17 '05 #5
Can you explain more detail about insert null value
Because I don't understand --
object.DateTimeField

Thank YOu
-----Original Message-----
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

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in messagenews:06****************************@phx.gbl...
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)

.

Nov 17 '05 #6
if ur using NullDate as the field containing the value to insert into the
DateTime field then
do
NullDate = DBNull.Value;

-PK

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in message
news:08****************************@phx.gbl...
Can you explain more detail about insert null value
Because I don't understand --
object.DateTimeField

Thank YOu
-----Original Message-----
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

"FatboyCanteen" <ze*******@fatboycanteen.com> wrote in

message
news:06****************************@phx.gbl...
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)

.

Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Phil Powell | last post: by
reply views Thread by M. Bader | last post: by
8 posts views Thread by Manish Jain | last post: by
1 post views Thread by Mike the Canadian | last post: by
2 posts views Thread by gradeA | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.