Compact MS Access Database

Compact MS Access Database

Postby Rick Lipkin » Thu Jan 17, 2013 7:00 pm

To All

I am trying to convert this VS Script to be able to programitally Compact a MS Access Database ..

Any help in converting this would be appreciated..

Thanks
Rick Lipkin
Code: Select all  Expand view

//---------
Module Module1

    Sub Main()

        Dim jro As JRO.JetEngine

        jro = New JRO.JetEngine()

        jro.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\nwind.mdb", _
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\NewNwind.mdb;Jet OLEDB:Engine Type=5")

        MsgBox("Finished Compacting Database!")
    End Sub

End Module
 


I did find some code that Enrico posted and and I have tried to use that code .. one additional problem is that I have a password on my database

Here is my attempt:

Code: Select all  Expand view

LOCAL cConStr1 := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\fox\travsql\travel.mdb;Jet OLEDB:Database Password=nov2012"
LOCAL cConStr2 := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\fox\travsql\new.mdb;Jet OLEDB:Database Password=nov2012"

Try
  oJro := CreateObject("JRO.JetEngine")
Catch
  MsgInfo( "Could not Create oJro object")
  oWndChild:End()
  Return(.f.)
End try

msginfo( "Success Create") // gets here fine

Try
   oJro:CompactDatabase( cConStr1, cConStr2 )// errors here
Catch
   MsgInfo( "Could not Compact the table "+xSource )
   oWndCHild:End()
   Return(.f.)
End Try

 


Here is some other code I found that does use a password

Code: Select all  Expand view

Dim jro As jro.JetEngine
    Set jro = New jro.JetEngine
    jro.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\nwind2.mdb;Jet OLEDB:Database Password=test", _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\abbc2.mdb;Jet OLEDB:Engine Type=4;Jet OLEDB:Database Password=test"

 


Any ideas ?

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 100 guests