Error Handling Why?

Results 1 to 2 of 2

Thread: Error Handling Why?

  1. #1
    Join Date
    Dec 1969

    Default Error Handling Why?

    Anyone know why the following error doesn&#039t get picked up with this error handling code?<BR>_____________<BR>error<BR>_________<BR> <BR>ADODB.Field error &#039 80020009&#039 <BR><BR>Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record. <BR><BR>_____________________<BR>code<BR>_________ ____________<BR><BR>&#060;% On Error Resume Next<BR> Set db = Server.CreateObject("ADODB.Connection")<BR> db.Open Session("ConnectionString")<BR> <BR> SQL = "SELECT * FROM tblProducts WHERE iNo = " & iNo & " "<BR> Set rsSelect = db.Execute(SQL)<BR> <BR> If Err.Number &#060;&#062; 0 Then <BR> da da da da da..................<BR>__________________________ __________<BR><BR>For some reason, Err.Number is always coming back as 0, even when the db cannot find the variable iNo.<BR><BR>Could it be that an "ADODB" error is not picked up in normal ASP error handling????<BR><BR>Any help would be most appreciated.<BR><BR>Thanks,<BR>Peter Jones<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Error Handling Why?

    If I&#039ve got right is you do set rs = conn.execute(...)<BR>check for error no error , then try to use rs("x") and it fails.<BR>If so, then follow me:<BR>you don&#039t get an error if query returns nothing, because nothing is failing, but if it does then EOF (and BOF) property of rs set to true.<BR><BR>After openning rs you should check for the property<BR>if accessing once then:<BR>if not rs.eof then<BR> response.write rs("x")<BR>end if<BR>rs.close &#039always do the close thing if open succeeded no metter if eof true or false.<BR><BR>if query returns number of records:<BR>do while no rs.eof<BR> response.write rs("x")<BR> rs.movenext<BR>loop<BR>rs.close<BR><BR>some are used to check also for bof.<BR>in short - search in 4guys site - for extensive help

Posting Permissions

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