Echivalent of PACK statement from FoxPro in VB.

I open a Fox database (.dbf) with DAO intrinsec control and use .Delete method
to delete a record, but this can't phisycally delete that record. It just mark it for delete like DELETE statement from FoxPro. What can I do to delete that record like PACK statement (from FoxPro) do ?
boggycAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Commented:
You must actually use the pack statement.

If you add a reference to Microsoft ActiveX data objects (ADO) to your project and add the following code:

    Dim cnnDBF As New ADODB.Connection
    Dim rstDBF As New ADODB.Recordset
    cnnDBF.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=Driver={Microsoft Visual FoxPro Driver};UID=;SourceDB=u:\;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"
    cnnDBF.Open
    rstDBF.Open "PACK DBF Lots1", cnnDBF
    cnnDBF.Close
    Set rstDBF = Nothing
    Set cnnDBF = Nothing

change the SourceDB section to your path and the Lots1 filename to your file and this will actually pack the .dbf file.

0
All Courses

From novice to tech pro — start learning today.