SQL and Dates!

Results 1 to 3 of 3

Thread: SQL and Dates!

  1. #1
    David Wyatt Guest

    Default SQL and Dates!

    Hi, can somebody please help with this code. Im trying only to display the new forum messages since the users last login.<BR><BR>Here is the code:<BR><BR>&#060;%<BR> Set objADOConnection = Server.CreateObject("ADODB.Connection")<BR> Set rsData = Server.CreateObject("ADODB.RecordSet")<BR> objADOConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("private_/forum.mdb") & ";" <BR> DavoSql = "SELECT * FROM FORUM_MESSAGES WHERE lastthreadpost=" & session("last_login") & ";"<BR> rsData.Open DavoSQL, objADOConnection, 2, 3<BR> If Rs.BOF And Rs.EOF Then<BR>%&#062;The database seems to be empty!&#060;%<BR> Else<BR> Do Until Rsdata.EOF<BR>%&#062;<BR><BR>&#060;%= rsData("topic")%&#062;<BR><BR>&#060;%<BR> Rs.MoveNext<BR> Loop<BR> End If<BR> rsData.Close<BR> objADOConnection.Close<BR> <BR> Set rsData = Nothing<BR> Set objADOConnection = Nothing<BR>%&#062;<BR><BR><BR><BR>But, im getting this error message. Why?<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039;80040e14&#039; <BR><BR>[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression &#039;lastthreadpost=13/08/2001 10:41:29&#039;. <BR><BR>/content/forum/general/forum_header.asp, line 1<BR><BR><BR>Any help is much appreciated.<BR><BR><BR>Thankyou<BR><BR><BR>David Wyatt

  2. #2
    Rhino Guest

    Default RE: SQL and Dates!

    Access databases need to have the date value surrounded in # marks like this:<BR><BR>DavoSql = "SELECT * FROM FORUM_MESSAGES WHERE lastthreadpost=#" & session("last_login") & "#;"<BR>

  3. #3
    David Wyatt Guest

    Default RE: SQL and Dates!

    thankyou. sorted :)

Posting Permissions

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