hi..
can you pls. give me a link on how to compact a msaccess database within vb6 project.
thanks,
alexis :p
Printable View
hi..
can you pls. give me a link on how to compact a msaccess database within vb6 project.
thanks,
alexis :p
use:
VB Code:
DBEngine.CompactDatabase("xyz.mdb","abc.mdb")
I think u need to refere DAO in your project...
Or else Use Microsoft JRO.
Add a reference to Microsoft Jet and Replication Objects 2.x Library by opening Project Menu. And then use this functionVB Code:
Public Function compactRepairMDB(ByVal sourceMDBPath As String, ByVal targetMDBPath As String) As Boolean Dim jetReplicationObject As JRO.JetEngine Set jetReplicationObject = New JRO.JetEngine jetReplicationObject.CompactDatabase _ "Provider=Microsoft.Jet.OleDB.4.0;Data Source=" _ & sourceMDBPath, "Provider=Microsoft.Jet.OleDB.4.0;Data Source=" _ & targetMDBPath compactRepairMDB = True Set jetReplicationObject = Nothing Exit Function CompactErr: compactRepairMDB = False End Function
You can use this function like thisVB Code:
JetReplication.compactRepairMDB("C:\db1.mdb", "C:\db2.mdb")
what are the things i should consider?? should the database be closed first?? how would i know if someone is still using the database?? can i check if the ".ldb" exists, does it mean someone is still using the database?? is it reliable??
I think it will gives an error if the file was opened..Handling the error will solve your problem easily rather than checking for ldb file..
ok thanks, i 'll try the code above.