Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a recordset

Status
Not open for further replies.

irocz

IS-IT--Management
Oct 28, 2001
25
US
Hi,
How can I permanently delete a recordset in .dbf format instead of marking it for deletion, without having to write a procedure to do it, which will involve copying the file?. I tried using the updatebatch method but did not work.
I am using VB6, and I know that in Clipper and in Visual Foxpro you can issue a function Zap, which will remove the marked for deletions record.
Thanks for your help.
 
In Clipper and FoxPro - the ZAP command not only removes the deleted records, its deletes EVERY record in the table.

PACK is the command that removed deleted records.

As far as issuing a PACK command via an ADO recordset, that is another question - but an interesting one, and one that I will look into.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Yes, sorry, I did mean PACK, although sometimes I would like to zap.
I was able to identify marked for deletion record by the "*" at the beginning of the record, and created another file(using binary) ignoring these records with the "*",and then renaming the file again.. which is a long process, and as the system grows, this file might become too large to continue with this process.
Thanks for your response
 
irocz,
I think I have the answer, at least it works with limited testing done so far.


Dim Cnn As ADODB.Connection

Set Cnn = New ADODB.Connection
Cnn.Open "Driver={Microsoft Visual FoxPro Driver};" & _
"SourceType=DBF;" & _
SourceDB=C:\FoxDatabase;" & _
"Exclusive=Yes;"

Cnn.Execute "PACK Products"

This was done using Microsoft ActiveX Data Object 2.7 Library.

Note that I did not connect to a table, but to the directory in which the DBF resides, the SourceDB holding the directory name

It is also required that the Exclusive parameter be set to yes.

Then issue the PACK command with the .Execute Method of the Connection with the table name that you wish to pack.

Also, you cannot have any recordsets open as you will get a File In Use error


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top