472,954 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 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 16218
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil Powell | last post by:
I have a mySQL database table with a column field datatype of datetime that I set up in the original create table statement like this: create table nnet_usermetadata ( .... nnet_record_entered...
0
by: M. Bader | last post by:
Hi, i'm struggling with updating session expire times in my login table. Can you tell me, how to correctly add an amount of seconds (after that the session expires) to a datetime field? ...
3
by: heroe | last post by:
Hello *, i write you with an urgent problem. I would like to create forign keys to datetime field, but it doesn't seem to work. I get Can't create table '.\sampleDB\student_module.frm' (errno:...
8
by: Manish Jain | last post by:
Platform : ASP.Net/C# void SomeFunction(DateTime date) { string text = date.ToString(); //This crashes if date is null } I am using a construct similar to above. I want to check if the date...
4
by: kd | last post by:
Hi All, I have a datetime column in a table on the SQL database. I need to insert values into the datetime column from vb.net code. Here is my code: dim nameval, str, qry as string nameval =...
1
by: Mike the Canadian | last post by:
Suppose I have a MySQL 5 table with a DateTime field in it. The table has two records where the time is blank. Running: SELECT CAST(DateTimeField AS TIME) FROM MyTable shows two records with...
2
by: gradeA | last post by:
Hi, I am having trouble inserting data into a datetime field in MSSQL. Here is the script I am trying to execute: $now = date('d/m/Y g:i:s A'); mssql_query("INSERT INTO clients...
1
by: Brad Pears | last post by:
I am using vb.net 2005 and SQL server 2000. In my table I have a date field of type "smalldatetime". In my vb application, the user may or may not enter a date value into the appropriate text box....
2
by: mzmishra | last post by:
Hi, How can I insert Null value to a DateTime field. Is there soem thing like DateTime dt=......something
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.