StrataFrame Forum

Can you ZAP or PACK a vfp free table through BO?

http://forum.strataframe.net/Topic23265.aspx

By Marcel Heitlager - 5/29/2009

Hi,



I'm trying to delete all the records in a VFP free table. Doing the deleting is no problem, but I want them permanently deleted, like ZAP or PACK.

Can you do something like below but with the PACK or ZAP command? I know it's a stupid question but I'm stuck.



thanks,

Marcel





Dim LoConn As New OleDb.OleDbConnection

LoConn.ConnectionString = MicroFour.StrataFrame.Data.DataLayer.DataSources("myKey").ConnectionString

LoConn.Open()

Dim loCommand As New OleDb.OleDbCommand("SET DELETED OFF", loConn)

loCommand.ExecuteNonQuery()

By Marcel Heitlager - 5/29/2009

OK,



So I did some more digging and did the obvious thing after "PACK" didn't work:





LoConn.ConnectionString = MicroFour.StrataFrame.Data.DataLayer.DataSources("myKey").ConnectionString

LoConn.Open()

Dim loCommand As New OleDb.OleDbCommand("PACK myFreeTable.dbf", loConn)

loCommand.ExecuteNonQuery()





Including the table name seems to work. So I guess to do something like ZAP I just have to delete all the records and do a PACK and put it in a myBO.Zap function.

Am I missing anything?



Thanks,



Marcel
By Michel Levy - 5/30/2009

Hi Marcel,

Are you sure your table is open EXCLUSIVE?

By Trent L. Taylor - 6/1/2009

You will have to open the table exclusively, but there is more. You need to create all of the commands that you wish to execute within the same session. When trying to do a PACK or a ZAP, you need to set exclusive on and then execute the pack within the same query session. Also, when dealing with VFP OLEDB, be sure to check the supported list. Also, even if you are not on the latest version of VFP in development, get the most recent VFP OLEDB provider if you run into any issues.



Here is a list of supported commands:

http://msdn.microsoft.com/en-us/library/80x51c04(VS.80).aspx



Here is a sample of packing using OLEDB:

Dim cmd As New OleDbCommand("SET EXCLUSIVE ON;PACK MyTable.dbf")



MyBo.ExecuteNonQuery(cmd);




Don't hold me to it, but I think that will work. Smile