-
I am working on a VB6 project using the DAO control to a .DBF file. I am trying to find a way to 'Compress' the data file after have run a SQL command to clear the Table. such as
sSQL = "delete * from pay"
DB.Execute (sSQL)
I do not wish to destroy the original table since I want to review the data after the program has stopped processing. :D <This is for debug purposes> :D
Any and all ideas are welcome.
-
'Compress'
Check out the CompactDatabase Method in the Visual Basic Help, a friend use it for compressing a Access file and it works very nice. Hope it help you out.
-
Thanks :D I'll give it a try..
-
Found an example...
> > **********************************************************
> > 'Passing values compactDB module
> > 'Sour_path = Source path of existing database.
> > 'Dest_Path = Target path
> > '
> > 'Note -
> > 'Add Microsoft Jet and Replication Objects X.X library,
> > 'where (X.X is greater than or equal to 2.1).
> > '***********************************************************
> > 'Jet OLEDB:Engine Type Jet x.x Format MDB Files
> > '********************* ************************
> > ' 1 JET10
> > ' 2 JET11
> > ' 3 JET2X
> > ' 4 JET3X
> > ' 5 JET4X
> > '**********************************************************
> >
> > Option Explicit
> >
> > Public Function compactDB(ByVal SOUR_path As String, _
> > ByVal DEST_path As String) As Boolean
> >
> > On Error GoTo Err_compact
> > Private JRO As New JRO.JetEngine
> >
> > ' Source and Destination connection path
> > Private DB_sour As String, DB_dest As String
> >
> > DoEvents
> > DB_sour = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
> > & SOUR_path
> > DB_dest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
> > & DEST_path & " ;Jet OLEDB:Engine Type=5"
> >
> > JRO.CompactDatabase DB_sour, DB_dest
> >
> > compactDB = True
> > Exit Function
> >
> > Err_compact:
> > compactDB = False
> > MsgBox Err.Description, vbExclamation
> > End Function
> >
> > '*************************************************
> > ' Usage Module level or form level.
> > '*************************************************
> >
> > ' Dim source_path,Target_path as string
> >
> > ' source_path=App.Path & "\Nwind.MDB"
> > ' Target_path=App.Path & "\CompactNwind.MDB"
> >
> > ' If not compactDB(source_path,Target_path) Then
> > ' MsgBox "An error occurred while attempt to rename database " _
> > ' & vbCrLf & vbCrLf & DBCP_Name, vbExclamation
> > ' End If