speedbit
asked on
How automatically doing Compact and Repair Database?
Hej!!
i noticed that MS Access Database size always become larger until i do compact and repair database! .. why its always doing like this.. whatever the reason i think its bad feature.. why MS Access not doing compact and repair automatically? .. is there a way for doing this automatically.. the problem that i'm using access database from delphi application.. how to do this automatically from external environment not from ms access .. !?
I'm using MS Access 2003
i noticed that MS Access Database size always become larger until i do compact and repair database! .. why its always doing like this.. whatever the reason i think its bad feature.. why MS Access not doing compact and repair automatically? .. is there a way for doing this automatically.. the problem that i'm using access database from delphi application.. how to do this automatically from external environment not from ms access .. !?
I'm using MS Access 2003
Hello speedbit,
In VB, you'd use code like this to compact and repair an access database....
Public Sub CompactAccessDataBase(dbPa th As String, NewPath As String)
Dim acc As Object
Set acc = CreateObject("Access.Appli cation")
acc.CompactRepair dbPath, NewPath
Set acc = Nothing
End Sub
Sub test()
CompactAccessDataBase "C:\YourDatabase.mdb", "C:\YourDatabase_NEW.mdb"
End Sub
Regards,
Wayne
In VB, you'd use code like this to compact and repair an access database....
Public Sub CompactAccessDataBase(dbPa
Dim acc As Object
Set acc = CreateObject("Access.Appli
acc.CompactRepair dbPath, NewPath
Set acc = Nothing
End Sub
Sub test()
CompactAccessDataBase "C:\YourDatabase.mdb", "C:\YourDatabase_NEW.mdb"
End Sub
Regards,
Wayne
ASKER
thank you, but i still need a code or method to automatically repair the database file from outside ms access
speedbit,
You can use that code I posted. By modifying it slightly, you can create a VB script file, and set it to run every so ofter via the Windows Task Scheduler.
Open Notepad, and paste in this code....
dim OldFile, NewFile, Acc,FSO, comp
OldFile = "C:\db1.mdb"
NewFile = "C:\db2.mdb"
Set acc = CreateObject("Access.Appli cation")
Set FSO = CreateObject("Scripting.Fi leSystemOb ject")
comp = acc.CompactRepair(OldFile, NewFile)
FSO.DeleteFile OldFile
FSO.MoveFile NewFile, OldFile
Set acc = Nothing
Set FSO = Nothing
Save the file as CompactDB.vbs, where ever you like.
Then add a new task to Scheduled Tasks, pointing it to the vbs file you created.
Wayne
You can use that code I posted. By modifying it slightly, you can create a VB script file, and set it to run every so ofter via the Windows Task Scheduler.
Open Notepad, and paste in this code....
dim OldFile, NewFile, Acc,FSO, comp
OldFile = "C:\db1.mdb"
NewFile = "C:\db2.mdb"
Set acc = CreateObject("Access.Appli
Set FSO = CreateObject("Scripting.Fi
comp = acc.CompactRepair(OldFile,
FSO.DeleteFile OldFile
FSO.MoveFile NewFile, OldFile
Set acc = Nothing
Set FSO = Nothing
Save the file as CompactDB.vbs, where ever you like.
Then add a new task to Scheduled Tasks, pointing it to the vbs file you created.
Wayne
ASKER
thank you but i need a delphi code
Hi,
i think you solution here:
https://www.experts-exchange.com/questions/20255768/Using-Access-repair-and-compact-ability-in-Delphi.html
i think you solution here:
https://www.experts-exchange.com/questions/20255768/Using-Access-repair-and-compact-ability-in-Delphi.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Everything you want to know about bloating mdbs
http://www.granite.ab.ca/access/bloatfe.htm
Good Luck!
Gary