Di bawah ini merupakan fungsi untuk mengcompact dan merepair database Microsoft Access. Kegunaan Compact And Repair database untuk menghilangkan secara permanen data-data yang terhapus. Bagaimana Fungsi mengenai Compact And Repair Database MS Access.
READ MORE - VB6 Code - Compact And Repair Database MS Access
Option ExplicitContoh penggunaan Compact and Repair Database:
Private Function CompactDB(Filename As String) As Boolean
On Error GoTo ErrHandler
Dim DC As New DBEngine
Screen.MousePointer = vbHourglass
DC.CompactDatabase Filename, App.Path & "\~database.tmp"
Kill Filename
Name App.Path & "\~database.tmp" As Filename
Screen.MousePointer = vbDefault
CompactDB = True
Exit Function
ErrHandler:
CompactDB = False
End Function
Private Sub Command1_Click()
MsgBox CompactDB(App.Path & "\database.mdb") 'true jika database sukses di compact dan repair
End Sub