SQL UPDATE for Dates ??

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

Guest

Hi folks,

I have 2 code snippets. One works and one does not.

This first hard-coded snippet works

Dim queryString As String = "UPDATE [rfi] SET [dateresolved] = '8/16/2006'
WHERE ([rfi].[id] = @id)"

This second snippet does not work

Dim dtNow As DateTime = DateTime.Now
dRes = dtNow.ToShortDateString
Dim queryString As String = "UPDATE [rfi] SET [dateresolved] = dRes WHERE
([rfi].[id] = @id)"

dateresolved is a Date/Time data-type. The first snippet uses single quotes
around the date but I would think the second snippet would be accepted as a
string. If I debug the value of dRes, I receive the proper format of
"8/16/2006"

Any clues you can leave me with?

Thanks,
- Glenn
 
Try "UPDATE rfi SET dateresolved = @dRes WHERE rfi.id = @id

where @dRes is a parameter in your parameter collection
 
Back
Top