473,387 Members | 1,465 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,387 software developers and data experts.

How to assign a null value to a date variable

Hi All,

Can anyone direct me or provide advice on how I can assign a null value to a
date variable in vb.net.
Basically what I'm doing is that I'm looping through a recordset where I
have three date fields that may or maynot have date values, if no date values
exists in the source field, the value is null. but when I pass a record from
the recordset to SQL command parameter query for record insertion into a
different table, the date values that are blank are inserting a date stamp of
00/00/1900 00:00:00 into my destination table. So is there anyway that I can
assign a null value to vb.net date variable so that when the date field is
blank a null value is inserted by my SQL insert statment.

many thanks,
Liamo

Jun 27 '06 #1
3 18608
Liam,

To give any answer on this I think that you has to tell what database you
use.

The date you shows let me think that you use the smalldatetime from
Microsoft, but it can of course be any other datebase. DateTime is in memory
01/01/00 00:00:00 and in SQL/Jet server 01/01/1753

Cor

"Liam Mac" <Li*****@discussions.microsoft.com> schreef in bericht
news:16**********************************@microsof t.com...
Hi All,

Can anyone direct me or provide advice on how I can assign a null value to
a
date variable in vb.net.
Basically what I'm doing is that I'm looping through a recordset where I
have three date fields that may or maynot have date values, if no date
values
exists in the source field, the value is null. but when I pass a record
from
the recordset to SQL command parameter query for record insertion into a
different table, the date values that are blank are inserting a date stamp
of
00/00/1900 00:00:00 into my destination table. So is there anyway that I
can
assign a null value to vb.net date variable so that when the date field is
blank a null value is inserted by my SQL insert statment.

many thanks,
Liamo

Jun 27 '06 #2
Hello, Liam!

[skipped]

LM> So is there anyway that I can assign a null value to vb.net date
LM> variable so that when the date field is blank a null value is inserted
LM> by my SQL insert statment.

Assign DbNull.Value to that field, this will repsent null value

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Jun 27 '06 #3
guy
look at either Nullable(of DateTime)
or the sqlDate datatype (assuming you are using sql server - there are
equivalents for other databases)

hth

guy

"Liam Mac" wrote:
Hi All,

Can anyone direct me or provide advice on how I can assign a null value to a
date variable in vb.net.
Basically what I'm doing is that I'm looping through a recordset where I
have three date fields that may or maynot have date values, if no date values
exists in the source field, the value is null. but when I pass a record from
the recordset to SQL command parameter query for record insertion into a
different table, the date values that are blank are inserting a date stamp of
00/00/1900 00:00:00 into my destination table. So is there anyway that I can
assign a null value to vb.net date variable so that when the date field is
blank a null value is inserted by my SQL insert statment.

many thanks,
Liamo

Jun 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matt | last post by:
If I assign VBScript server side variable a to javascript variable x, it is fine. <% Dim a, b a = 10 %> var x = <%= a %>; alert(x); But if I do the other way around, then it has 500 error....
2
by: Harry Stangel | last post by:
Noble reader, My goal is to obtain the current time on the web server and display it in the client's browser. I want the server time displayed independent of the client's current clock setting,...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
8
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
8
by: JIM.H. | last post by:
Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate=”” gives error in asp.net, how should I do...
2
by: Jim McGivney | last post by:
In asp 2.0 I am trying to insert a row using a detailsview control connected to an accessDataSource. I get the error message below. I am having trouble identifing which data field is causing the...
5
by: AAJ | last post by:
Hi Does anyone know of any good publically available set of standards for managing dates when dealing with a database server (in my case SQL Server 2000 and c# VS2005). At the moment, if I...
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....
9
by: raylopez99 | last post by:
Just an observation: pens for drawing lines in Win Forms are tricky when assignment is inside the paint handler. inside of the Paint handler, but not inside a "using" brace (that is, outside of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.