Solved

How to handle the syntax for a Null date field in a SQL SERVER database using VB.NET

Posted on 2007-11-29
2
222 Views
Last Modified: 2010-05-18
I have a SQL statement..

 Dim str As String = "UPDATE tExpress SET dtBagReturned = '" & lDate & "' WHERE iCustomerID = " & lnCustomerID

I only want to update the table if dtBagReturned is empty...how would the syntax look for a null date field in  a SQL server database..

Somebody me told a empty date field defaults to a value of # 01/01/01 12:00:00 AM #...so it is not realy empty..

I'm confused on how to change my sql to reflect the " empty" date field

Anyhelp or insight would be much appreciated...
           
0
Comment
Question by:nomar2
2 Comments
 
LVL 5

Expert Comment

by:mydasx
ID: 20375814
compare your result to SQLDATETIME.NULL
0
 
LVL 3

Accepted Solution

by:
bnaveke earned 33 total points
ID: 20375904
Dim str As String = "UPDATE tExpress SET dtBagReturned = '" & lDate & "' WHERE iCustomerID = " & lnCustomerID & " and dtBagReturned is null"

or

Dim str As String = "UPDATE tExpress SET dtBagReturned = '" & lDate & "' WHERE iCustomerID = " & lnCustomerID & " and isnull(dtBagReturned)"


0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question