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
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

710 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