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!

Compacting MSAccess Database File (.MDB) in ADO

Status
Not open for further replies.

dotnetprogrammer

Programmer
Aug 17, 2000
77
0
0
US
How do I compact MSAccess Database (.MDB) File in VB and ADO?
Thanks,
fred
 
Dim JRO As JRO.JetEngine
Dim stSource
Dim stTarget

PW$ = "Password"

Set JRO = New JRO.JetEngine

Access.Close

stSource = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=pdp.mdb;Jet OLEDB:Database Password=" & PW$

stTarget = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=pdp1.mdb;Jet OLEDB:Engine Type=5;Jet OLEDB:Database Password=" & PW$
Call JRO.CompactDatabase(stSource, stTarget)

Kill "pdp.mdb"
Name "pdp1.mdb" As "pdp.mdb"

Set Access = New ADODB.Connection
Access.CursorLocation = adUseClient
On Error GoTo errCheck
Access.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=pdp.mdb;Jet OLEDB:Database Password=" & PW$
On Error GoTo 0
Exit Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top