Discussion:
remove deleted records dbase
(too old to reply)
alin
2005-03-22 07:29:02 UTC
Permalink
I'm using dao 2.5 to delete records from dbf file.
Set dbDatab = Workspaces(0).OpenDatabase(...)
Set rst = dbDatab.OpenRecordset ...
rst.Delete

The records are deleted, but when open dbf file i saw records are marked as
'deleted'. How can i remove Permanently this records from dbf file within
visual basic ?
Thanks
Casey Provance
2005-03-22 08:03:14 UTC
Permalink
After the rst.Delete statement, you need to include: rst.Update

This way the database will update. :)

ps - Dont forget the rst.Close

- Kev
Post by alin
I'm using dao 2.5 to delete records from dbf file.
Set dbDatab = Workspaces(0).OpenDatabase(...)
Set rst = dbDatab.OpenRecordset ...
rst.Delete
The records are deleted, but when open dbf file i saw records are marked as
'deleted'. How can i remove Permanently this records from dbf file within
visual basic ?
Thanks
alin
2005-03-22 08:35:04 UTC
Permalink
Wrong answer. Update is only used when add and edit. Howevere I found a
solution :
Dim cmd1 As New ADODB.Command
Set conn1 = New ADODB.Connection
conn1.Open _
"Provider=VfpOleDB.1;" & _
"Data Source=" & path & ";"


Set cmd1 = New ADODB.Command
cmd1.CommandType = adCmdText
Set cmd1.ActiveConnection = conn1
cmd1.CommandText = "Set Exclusive On"
cmd1.Execute
cmd1.CommandText = "pack " & tbl
cmd1.Execute
conn1.Close
Post by Casey Provance
After the rst.Delete statement, you need to include: rst.Update
This way the database will update. :)
ps - Dont forget the rst.Close
- Kev
Post by alin
I'm using dao 2.5 to delete records from dbf file.
Set dbDatab = Workspaces(0).OpenDatabase(...)
Set rst = dbDatab.OpenRecordset ...
rst.Delete
The records are deleted, but when open dbf file i saw records are marked as
'deleted'. How can i remove Permanently this records from dbf file within
visual basic ?
Thanks
Paul Clement
2005-03-22 16:51:30 UTC
Permalink
On Tue, 22 Mar 2005 00:35:04 -0800, "alin" <***@discussions.microsoft.com> wrote:

¤ Wrong answer. Update is only used when add and edit. Howevere I found a
¤ solution :
¤ Dim cmd1 As New ADODB.Command
¤ Set conn1 = New ADODB.Connection
¤ conn1.Open _
¤ "Provider=VfpOleDB.1;" & _
¤ "Data Source=" & path & ";"
¤
¤
¤ Set cmd1 = New ADODB.Command
¤ cmd1.CommandType = adCmdText
¤ Set cmd1.ActiveConnection = conn1
¤ cmd1.CommandText = "Set Exclusive On"
¤ cmd1.Execute
¤ cmd1.CommandText = "pack " & tbl
¤ cmd1.Execute
¤ conn1.Close
¤

I forgot about the FoxPro driver. Definitely better than my suggestion.


Paul
~~~~
Microsoft MVP (Visual Basic)
Casey Provance
2005-03-23 01:15:37 UTC
Permalink
Post by alin
Wrong answer.
Sorry, I didn't realize it was a contest.

- Kev

Paul Clement
2005-03-22 16:50:01 UTC
Permalink
On Mon, 21 Mar 2005 23:29:02 -0800, "alin" <***@discussions.microsoft.com> wrote:

¤ I'm using dao 2.5 to delete records from dbf file.
¤ Set dbDatab = Workspaces(0).OpenDatabase(...)
¤ Set rst = dbDatab.OpenRecordset ...
¤ rst.Delete
¤
¤ The records are deleted, but when open dbf file i saw records are marked as
¤ 'deleted'. How can i remove Permanently this records from dbf file within
¤ visual basic ?
¤ Thanks
¤

It's actually pretty ugly since there are no native zap or pack methods for dBase when using the Jet
database engine:

How to ZAP or PACK a dBASE or FoxPro Table
http://support.microsoft.com/default.aspx?scid=kb;en-us;119116


Paul
~~~~
Microsoft MVP (Visual Basic)
Loading...