rjm
10-26-2004, 08:02 AM
In foxpro, deleting a record does not physically delete the record, it just flags it for deletion. In order to physically remove the record(s), I have to issue the PACK command but I am having problems with it.
Does anyone know the proper way to issue this command?
Thanks in advance for any help.
' Code
With rsObjectRS
'-- Delete all records from Customer table
.ActiveConnection = dbObjectDB
.Source = "SELECT * FROM Customer WHERE CustomerID = " & cCustomer.CustomerID
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.Open
If rsObjectRS.EOF = False Then
.Delete adAffectCurrent
End If
.Close
dbObjectDB.CommitTrans
' * * My records are flagged for deletion up to here, but not yet removed
' How do you issue the PACK command from this point on?
dbObjectDB.Close
dbObjectDB.Mode = adModeReadWrite
dbObjectDB.Open "Provider=VFPOLEDB.1;Data Source=" & App.Path & ";Mode=ReadWrite|Share Deny" _
& " None;Collating Sequence=MACHINE"
dbObjectDB.BeginTrans
.ActiveConnection = dbObjectDB
.Source = "PACK Customer"
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.Open
dbObjectDB.CommitTrans
End With
Does anyone know the proper way to issue this command?
Thanks in advance for any help.
' Code
With rsObjectRS
'-- Delete all records from Customer table
.ActiveConnection = dbObjectDB
.Source = "SELECT * FROM Customer WHERE CustomerID = " & cCustomer.CustomerID
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.Open
If rsObjectRS.EOF = False Then
.Delete adAffectCurrent
End If
.Close
dbObjectDB.CommitTrans
' * * My records are flagged for deletion up to here, but not yet removed
' How do you issue the PACK command from this point on?
dbObjectDB.Close
dbObjectDB.Mode = adModeReadWrite
dbObjectDB.Open "Provider=VFPOLEDB.1;Data Source=" & App.Path & ";Mode=ReadWrite|Share Deny" _
& " None;Collating Sequence=MACHINE"
dbObjectDB.BeginTrans
.ActiveConnection = dbObjectDB
.Source = "PACK Customer"
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.Open
dbObjectDB.CommitTrans
End With