locked
Error trapping RRS feed

  • Question

  • User-863835478 posted
    I have the following legacy code for trapping errors: On Error Resume Next Dim adoError As ADODB.Error 'Any sort of database operation here ... If adoCn.Errors.Count Then For Each adoError In adoCn.Errors Debug.Print "Error " & adoError.Number & ": " _ ; adoError.Description & vbCrLf & _ "NativeError: " & adoError.NativeError & vbCrLf & _ "SQLState: " & adoError.SQLState & vbCrLf & _ "Reported by: " & adoError.Source & vbCrLf & _ "Help file: " & adoError.HelpFile & vbCrLf & _ "Help Context ID: " & adoError.HelpContext Next End If Anyone knows how to convert the above ADO Errors object to ADO.NET? Thanks much.
    Thursday, March 17, 2005 1:14 PM

All replies

  • User44722370 posted

    First if you are using ADO.net, in VB.Net you would use a TRY-Catch block.

    second you can catch SQL exceptions in the Try-Catch block by Catching the SQL Exceptions something like this

    TRY

       'Your code here

    Catch sqlEx as sqlException
       'Do something with sqlex like display it in a message box
       messagebox.show(ex.message)
    Catch ex as System.Exception
       Throw EX
    End Try

     

    Thursday, April 28, 2005 1:57 PM
  • User-863835478 posted
    Please kindly advise how to display details on the error like the legacy example shows? Thanks again.
    Thursday, April 28, 2005 3:05 PM