After reading the posts over, I think that I may have given the impression that the purpose behind the development of ADO was to spilt up the functionality of DAO into three modules. That is certainly not the case, nor was it my intention. What I meant to say, was that during the development of ADO model, they wanted to be sure that all of the functionality that currently existed in the DAO would be available somewhere within the new ADO model.
As a separate and distinct point, the developers understood that the single DAO model had a memory usage drawback, and they didn't want to do that again with ADO, so they took the overall functionality of ADO, and based on function and expected usage, broke it out into ADO, ADOX, and JRO.
If I confused anyone, or gave the wrong impression I apologize.
'----------------------------------------------------------
Now to the point: How to Trap the Error of the Corrupted Database.
This is an example of an error handler that I have used.
Private Sub Some_Proc()
If (gBol_UseErrorHandler) Then
On Error GoTo HandleError
End If
<The Code>
Exit Sub
HandleError:
ErrMessage "Some Useful Info", "ModuleName.Some_Proc"
Resume Next
End Sub
Then in a module, I have the following:
Const ADO_ERROR = -2147467259
Public Sub ErrMessage(rStr_Err As String, rStr_Title As String)
Dim lRst_Error As ADODB.Error
Dim lStr_Msg As String
Dim lStr_ErrDesc As String
Dim lLng_ErrorNumb As Long
lLng_ErrorNumb = Err.Number
lStr_Msg = "PROC" & vbTab & ": " & rStr_Title & vbCrLf & vbCrLf & _
"REFER" & vbTab & ": " & rStr_Err & vbCrLf & vbCrLf & _
"ERROR" & vbTab & ": "
If (Err.Number = ADO_ERROR) Then
For Each lRst_Error In gADO_Connect.Errors
lStr_ErrDesc = lRst_Error.Description
If (Left(lStr_ErrDesc, 32) = "[Microsoft][ODBC Driver Manager]"
Then
lStr_Msg = lStr_Msg & "[Microsoft][ODBC Driver Manager]" & vbCrLf
lStr_ErrDesc = vbTab & ": " & Mid(lStr_ErrDesc, 34)
End If
lStr_Msg = lStr_Msg & lStr_ErrDesc & vbCrLf & vbCrLf & vbTab & _
" (Source" & vbTab & vbTab & ": " & lRst_Error.Source & "
" & _
vbCrLf & vbTab & _
" (SQL State" & vbTab & ": " & lRst_Error.SQLState & "
" & _
vbCrLf & vbTab & _
" (NativeError" & vbTab & ": " & lRst_Error.NativeError & "
" & vbCrLf
Next
Else
lStr_Msg = lStr_Msg & Err.Number & " -- " & Err.Source & vbCrLf & Err.Description
End If
Debug.Print lStr_Msg
lStr_Msg = lStr_Msg & vbCrLf & vbCrLf & "ACTION" & vbTab & ": " & _
"Please Notify System Administrator"
MsgBox lStr_Msg, vbExclamation + vbOKOnly, "An Error Has Occurred"
End Sub
As to the specifics, when you encounter the corrupted database, this should trap the error, but the standard Err.Number will probably be ADO_ERROR (-2147467259). In this code, I walk the the ADO.Error objects extracting specific information about ADO Errors. I do not know what will be there for the "Corrupted Database" error, but I would with a watch, inspect that ADO Error Object, probably paying the most attention to the ADOError.NativeError property value. I don't know for sure, but I suspect that you'll have a certain value in ADOError.NativeError for the Corrupted Database.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein