Compacting an Access Database using ODBC 2.0 
Author Message
 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.)



Sat, 27 Nov 1999 03:00:00 GMT  
 Compacting an Access Database using ODBC 2.0

Quote:
>     sOptions = sOptions & "COMPACT_DB=c:\mypath\mydb.mdb
> c:\mypath\mydb1.mdb General" & Chr(0)

I think General is a numneric constant with the Value DB_general

sOptions = sOptions & "COMPACT_DB=c:\mypath\mydb.mdb c:\mypath\mydb1.mdb
0 " & Chr(0)

should do



Mon, 29 Nov 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Accessing Access 2.0 database with VB3, ODBC 2.0 and Microsotf Jet Engine Compatibility Layer

2. Problems accessing ACCESS 2.0 databases from ODBC

3. compacting a database connected using odbc

4. ODBC error after compacting Access 97 database

5. Closing ODBC Access 2.0 database

6. VB3 using Access 2.0 db thru ODBC

7. Using Access 2.0 via ODBC from VB

8. using access databases by using ODBC

9. Compacting Access Database using ADO

10. Rempare/Compacting Access Databases using VB5

11. Using VBScript to compact an Access 97 Database

12. Compact Access Database Using VB 6

 

 
Powered by phpBB® Forum Software