SQL UPDATE with a DATE data-type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi folks,

I am doing an UPDATE to a table that has a field for a DATE data type. I am
using MS Access.

The UPDATE works fine but when I try to place the DATE field in the mix it
blows up.

The table name is rfi.

Here's a code snippet...
Dim dtNow As DateTime = DateTime.Now
UPDATE [rfi] SET [dateresolved]=dtNow WHERE ([rfi].[id] = @id)

It does not like dtNow, so I tried using dtNow.ToString ( ) which it also
did not like.
Next I changed the data-type for the dateresolved field from DATE to STRING
and tried to put in dtNow.ToString ( ) which it still did not like.

Finally, I hard coded a string in as "8/15/2006" which it accepted both as a
DATE type and as a STRING type.

Any ideas on what I may be missing would be appreciated.

- Glenn
 
Hi Glenn,

Use SqlParameter/OleDbParamter when communication with databases, it will
convert .net data types to sql/oledb data types for you.
 
Back
Top