FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Compact MS Access Database
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Compact MS Access Database
Posted: Thu Jan 17, 2013 07: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 (fw): Select all Collapse
//---------
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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

Continue the discussion