VB菜鸟 2005-9-17 13:18
如何修复被破坏了的数据库(ACCESS)
'ACCESS数据库是桌面型数据库,如果在程序对数据库操作比较频繁或并发操作较多,则建议还是将数据库换成SQL
---------------------------------------------------------------
[code]ADOX:
Dim jro As jro.JetEngine
Set jro = New jro.JetEngine
jro.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:
wind2.mdb", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:abbc2.mdb;Jet OLEDB:Engine Type=4"
DAO:
DBEngine.CompactDatabase "C:Db1.mdb", "C:Db2.mdb"
---------------------------------------------------------------
用代码修复:
Public Function RepairDB(ByVal sDbName As String) As Boolean
RepairDB = True
DBEngine.RepairDatabase sDbName
Exit Function
Err_Repair:
RepairDB = False
MsgBox Err & vbCrLf & vbCrLf & Err.Description
End Function
[/code]