Forum Moderators: open

Message Too Old, No Replies

Facing Problem trapping errors in VB

Help me out plz

         

coolsam

8:18 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



I was executing an insert command on a Oracle database table with VB at the front end. The "Insert" command caused a referential integrity constraint to be violated on that specific database table hence an error msg was generated which caused the VB program to terminate. I was unable to trap the error using VBs error object.

Plzz suggest some way to trap the error.

duckhunter

8:59 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



On Error Resume Next

sSQL = "Insert into......."
DBConn.Execute sSQL

If DBConn.errors.count > 0 then
If DBConn.errors.item(0).number <> 0 then
response.write "Error Executing " & sSQL & " - Error: " & DBConn.errors.item(0).description
end if
end if

coolsam

6:27 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



thanks mate!

KenpoMatt

2:07 am on Dec 19, 2003 (gmt 0)

10+ Year Member



DON'T FORGET: You have to turn off error trapping when you're done in classic VB (ver 4, 5, 6).


'turn on error handling
On Error Resume Next

...some code that might cause an error

If Err.Number <> 0 then
...handle the error
End If

'turn off error handling
On Error Goto 0