473,394 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 16236
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
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.