Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
251 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 132 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 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