Help! Help! On error resume next

Results 1 to 2 of 2

Thread: Help! Help! On error resume next

  1. #1
    Join Date
    Dec 1969

    Default Help! Help! On error resume next

    Does "On error resume next" work as advertised? Is it supposed to execute the next statement after the query that caused the error. I am getting some strange results using this. It doesn&#039;t get to the If statement: <BR> On error resume next<BR> someUpdateQuery<BR> If (Err.number &#060;&#062; 0)<BR> someErrMsg<BR> Redirect someWhere

  2. #2
    Join Date
    Dec 1969

    Default If it doesn't get ... the IF statement, that means it must give you an error message on the query, yes?<BR><BR>Somehow, I suspect that what you *MEAN* is that the IF statement doesn&#039;t do what you expected it to do.<BR><BR>And that might be because, when you work with ADO, there are *two* ways to get errors. In the Err object, as you are checking for. But also in the ADODB.Connection.Errors collection. Which you are not checking for.<BR><BR>(Also, you really should "turn off" the error handling ASAP, so that you aren&#039;t masking other unrelated errors.)<BR><BR>So:<BR><BR>&#060;%<BR>...<BR>conn. Open ... open the connection ...<BR>conn.Errors.Clear &#039; clear out all errors<BR><BR>On Error Resume Next<BR>conn.Execute ... whatever ...<BR>On Error GoTo 0 &#039; do this ASAP!<BR>If Err.Number &#060;&#062; 0 Then<BR>&nbsp; &nbsp; ...<BR>End If<BR>For Each oops In conn.Errors <BR>&nbsp; &nbsp; Response.Write "DB error: " & oops.Number ...<BR>&nbsp; &nbsp; ...<BR>Next<BR>...<BR>%&#062;<BR><BR>Obviously, you don&#039;t want to just Response.Write when you get an error from that collection, but you get the idea.<BR><BR>NOTE: You can *also* get warnings in the conn.Errors collection, so you might want to check for specific values of oops.Error in your code and decide what to do based on the value(s).<BR><BR>Yes, you can get more than one DB error from a single DB operation.<BR><BR>

Posting Permissions

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