Updated a date field in MSAccess

Results 1 to 2 of 2

Thread: Updated a date field in MSAccess

  1. #1
    Join Date
    Dec 1969

    Default Updated a date field in MSAccess

    I&#039;m getting this error when I try updating a date field in an MSAccess database:<BR>Microsoft OLE DB Provider for ODBC Drivers (0x80004005)<BR>[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.<BR><BR>Here&#039;s my code:<BR>Dim objCustr, idtomod, done<BR>Set objCustr = Server.CreateObject("ADODB.Recordset")<BR>objCustr .Open "tblCustr", objConn, , adLockOptimistic, adCmdTable<BR>idtomod = Request.Form("idtomod")<BR>done = False<BR>Do While Not done<BR> If objCustr("OrderID") = Cint(idtomod) Then<BR> response.write typename(cdate(request.form("date")))<BR> objCustr("Email") = Request.Form("email")<BR> objCustr("Date") = cdate(request.form("date"))<BR> objCustr.Update<BR> done = True<BR> End If<BR> objCustr.MoveNext<BR> If objCustr.EOF Then<BR> done = True<BR> End If<BR>Loop<BR><BR><BR>The error is on the update line, but when I don&#039;t try to update the date, it works fine. Is this a limitation in the MSAccess ODBC implementation?

  2. #2
    Join Date
    Dec 1969

    Default Why would you ever do this...

    ...in any case?<BR><BR>Looping through all the records to change only selected records?<BR><BR>SLOOOOOOOOOWWWW.<BR><BR>&#060;%<BR >email = Replace( Request("Email"), "&#039;", "&#039;&#039;" )<BR>theDate = CDate( Request("Date") )<BR>idtomod = CLNG( Request("idtomod")<BR>SQL = "UPDATE tblCustr " _<BR> & " SET EMail=&#039;" & email & "&#039;, [Date]=#" & theDate & "# " _<BR> & " WHERE OrderID = " & idtomod<BR>objConn.Execute SQL<BR>%&#062;<BR><BR>Presto. Done.<BR><BR>Oh...I *think* the problem is the name of your field: DATE is a reserved word. In SQL we can get around that by putting [...] around the name, as I did. Dunno how you get around it with the update loop version.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts