Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect Corruption of mdb

Status
Not open for further replies.

mehrnosh

Programmer
Dec 17, 2002
35
0
0
HK
Hi

Is there any way by which one can Detect the Corruption
of Ms Access database (mdb) before it gets corrupted and
repair is required. There by avoiding inconvenience to the
user

Thanks
 
Curruption useally takes place when a user is shutting down in the middle of an update i.e. reset etc. so I do not think that one can detect this in advance.
Curruption in A2K and AXP are not common but in A97 etc. it was "normal".
I you want to ensure a no curruption back-end you could think about using an SQL back-end for your MDB via an ODBC, by upsizing your back-end to SQL - if your client does not use or du not want to invest in an SQL-server use an MSDE (run-time-SQL-server).
Herman
 
Me is use a Function when a trap a error in DAO.

If you have a corrupt database when you try to open in DAO the error #3343 (Access 97) is display and description of the name and the path of database corrupted. Finaly i extract the name and the path from description i pass in the Function to Repair and Compact DB.

Private Function MyFunction()

Dim bRetry as Boolean

On Error Goto MyFunction_Err
Set db= OpenDatabase("C:\Test\DBCorrupt.mdb")

etc...

db.close:set db = nothing
Exit Function

MyFunction_Err:
DisplayErrorMessage Err.Number, Err.Description, "MyFunction", bRetry
Err.Clear
if bRetry then Resume
set db = nothing

End Function

Public Sub DisplayErrorMessage(varErrorNum As Variant, strDescription As String, strSubFunctionName As String, bRetry As Boolean)

Const ERR_BD_CORRUPTION As Variant = 3343

If varErrorNum = ERR_BD_CORRUPTION Then

'Extract Path and Database Name from Description.
For iCounterX = 1 To Len(strDescription) - 5
If MID(strDescription, iCounterX, 5) = ".mdb'" Then
Exit For
End If
Next iCounterX

For iCounterY = iCounterX To 1 Step -1
If MID(strDescription, iCounterY, 1) = "'" Then
iCounterY = iCounterY + 1
Exit For
End If
Next iCounterY

strDB = MID(strDescription, iCounterY, iCounterX - iCounterY) & ".mdb"

If ToolsCompactRepairDB(strDB, False, True) Then
bRetry = True
End If
End If

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top