Syntax error in SQL (Error Handling)

Results 1 to 2 of 2

Thread: Syntax error in SQL (Error Handling)

  1. #1
    Join Date
    Dec 1969

    Default Syntax error in SQL (Error Handling)

    I&#039;m trying to capture a syntax error in my SQL on a ASP page. If there is a syntax error in my SQL then I need to redirect somewhere else. I do know the reason for my syntax error, because the session in the where clause has been cleared. The reason for this is to prevent the user from clicking the back button, because at the last page I do a Session.Abandon toclear sessions. Is there a way to capture this. Here is some of my code below. Also, I show at bottom the error I get in the IE 5.0 browser. Any help would be greatly appreciated.<BR><BR>here&#039;s my where clauseand recordset with execution...<BR>"WHERE tblEmployee.[Id Number] = " & Session("iIdNum") & ";"<BR><BR>Set objEmpDataRS = Server.CreateObject("ADODB.Recordset")<BR>objEmpDa taRS.CursorLocation = adUseClient<BR>objEmpDataRS.Open strEmpDataSQL, objConn, adOpenStatic, adLockPessimistic, adCmdText<BR><BR>here&#039;s where I try to capture the error...<BR>For Each objError in objConn<BR> ErrorInfo = "Description; " & objError.Description <BR> "Help Context: " & objError.HelpContext "Help File: " & objError.HelpFile <BR> "Native Error: " & objError.NativeError "Number: " & objError.Number "Source: " & objError.Source <BR> "SQL State: " & objError.SQLState<BR><BR> Response.Write ErrorInfo<BR>Next<BR><BR>this is the error I receive in the browser...<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;tblEmployee.[Id Number] =&#039;. <BR><BR>/fsc/cust/review.asp, line 113 <BR>

  2. #2
    Join Date
    Dec 1969

    Default On Error..

    Set objEmpDataRS = Server.CreateObject("ADODB.Recordset")<BR>objEmpDa taRS.CursorLocation = adUseClient<BR><BR>On Error Resume Next<BR>objEmpDataRS.Open strEmpDataSQL, objConn, adOpenStatic, adLockPessimistic, adCmdText<BR><BR>If Instr(err.Description, "Hello") Then<BR>Response.Redirect "login.asp"<BR>Else<BR>...<BR>end if<BR><BR><BR>HTH<BR><BR>Jerry

Posting Permissions

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