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
230 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net and creating a class 5 20
VB.net SQLCommandBuilder Insert New Records From DataGridView 3 25
Code enhancement 4 22
VB.NET Inline If statement 4 18
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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