
Compacting an Access Database using ODBC 2.0
Hi!
I'm using VB4/32 and ODBC 2.0. I want to Compact and to Repair an Access
database using ODBC. I can Repair it, but I can't compact it. Can anyone
help me? Here's the code I'm using.
Private Sub Command1_Click()
Dim sOptions As String
sOptions = ""
sOptions = sOptions & "UID=Myself" & Chr(0)
sOptions = sOptions & "PWD=MyPassWord" & Chr(0)
sOptions = sOptions & "COMPACT_DB=c:\mypath\mydb.mdb
c:\mypath\mydb1.mdb General" & Chr(0)
sOptions = sOptions & Chr(0)
If SQLConfigDataSource(0, ODBC_CONFIG_DSN, "Microsoft Access Driver
(*.mdb)", sOptions) Then
MsgBox "OK"
Else
MsgBox "Error"
End If
End Sub
Private Sub Command2_Click()
Dim sOptions As String
sOptions = ""
sOptions = sOptions & "UID=Myself" & Chr(0)
sOptions = sOptions & "PWD=MyPassWord" & Chr(0)
sOptions = sOptions & "REPAIR_DB=c:\mypath\mydb.mdb" & Chr(0)
sOptions = sOptions & Chr(0)
If SQLConfigDataSource(0, ODBC_CONFIG_DSN, "Microsoft Access Driver
(*.mdb)", sOptions) Then
MsgBox "OK"
Else
MsgBox "Error"
End If
End Sub
The code for repairing the DB works fine, but the one I use for compacting
the DB doesn't, even though they are almost the same. Does anyone have an
idea?
--------------------------
Ghislain Gadbois
Sisca inc.
Sherbrooke (Qu.)