ADO Errors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Whats the way to capture ADO Errors. Errors that are returned from SQL Server
2000. Like constrain erros. Where must I put the error number and how can I
find this number, before it is displayed from MS Access 2003.

Thanks
 
pstavros schreef :
Whats the way to capture ADO Errors. Errors that are returned from SQL Server
2000. Like constrain erros. Where must I put the error number and how can I
find this number, before it is displayed from MS Access 2003.

Thanks

if cnn is your ADODB.connection object:

Dim objError As ADODB.Error
Dim strError As String

If cnn.Errors.Count > 0 Then
For Each objError In cnn.Errors
strError = strError & "Error #" & objError.Number & _
" " & objError.Description & vbCrLf & _
"NativeError: " & objError.NativeError & vbCrLf & _
"SQLState: " & objError.SQLState & vbCrLf & _
"Reported by: " & objError.Source & vbCrLf & _
"Help file: " & objError.HelpFile & vbCrLf & _
"Help Context ID: " & objError.HelpContext
Next
MsgBox strError
End If
 
Back
Top