Re: SQL UPDATE for date data-type
- From: "Mark Rae" <mark@xxxxxxxxxxxxxxxxx>
- Date: Wed, 16 Aug 2006 16:26:29 +0100
"glenn" <glenn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:69AED76D-F11A-4E5D-9E8E-AE32AF7445C7@xxxxxxxxxxxxxxxx
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"
Yes, but SQL Server doesn't know that. If you're building up your SQL
dynamically, then you need to format it properly...
Dim queryString As String = "UPDATE [rfi] SET [dateresolved] = '" &
dRes.ToString("dd MMM yyyy") & "' WHERE ([rfi].[id] = @id)"
Any clues you can leave me with?
Use parameterised queries or, better still, stored procedures.
.
- Prev by Date: odbc with vfp
- Next by Date: Re: Getting a value out of XML
- Previous by thread: odbc with vfp
- Next by thread: Re: SQL UPDATE for date data-type
- Index(es):