Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!

 

I am trying to to SQL updates with an access database. One of the fields is a Date/Time field, and the problem occurs when I do n ot want to insert a date.

 

Now I have:


Dim strDate as String = Format(myDate, "yyyy-MM-dd HH:mm:ss")

Dim strSQL as String = "Update myTable SET date1 ='" & strDate & "' WHERE..."

 

This works fine as long as I have a date to insert...

 

I have tried stuff like...

 

Update myTable SET date1 ='" & IIF(strDate="", "Null", strDate) & "'

 

...but I can't make it work...

 

 

Does anyone know how to update datetimefields with null values?

 

 

noccy

Posted

Hi,

First of all I have to say....

You should use parameters, make things a lot easier

 

If you still want to create a string there shall be no quotes around the NULL keyword...

Update myTable SET date1 =null where 1=2

 

HTH

/Kejpa

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...