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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pack Command

Status
Not open for further replies.

Sware

Programmer
Apr 19, 2005
124
US
I'm back - same Visual Basic application using ADO and a VFPOLEDB connection. The application does not have a database (.DBC), just free tables (.DBF). I'm trying to Pack one of the tables with the following code.

Code:
rs1.Close    'Closes the recordset related to the table
Set rs1 = Nothing
conn1.Execute ("SET EXCLUSIVE ON")
conn1.Execute ("PACK GHM_V70.DBF")
I'm getting an error on the Pack statement that the file is in use - ???

On a separate problem, I'm using:

conn1.Execute ("SET DELETED OFF")

as a basis the counting the number of physical records, i.e. both deleted and undeleted records. It isn't effective because I'm getting a count of only the undeleted records.

Thanks.
 
try to execute

Code:
USE IN SELECT([GHM_V70])
PACK GHM_V70

Tables are usually open with an sql you did before, USE IN SELECT(name) does handle this and does not error, if the table is not open.

You get the reccordcount with RECCOUNT(), regardless of SET DELETED ON or OFF, but DELETED OFF is the right setting and it should be available/supported. It may be able to set deleted with the connection string, try deleted=no within the connection string. I found the following additional settings in the connection string in anoher tek-tips thread (thread1253-1300364):

Exclusive=no/yes;BackGroundFetch=no/yes;NULL=no/yes;Collate=MACHINE/GENERAL/GERMAN...;Deleted=no/yes

Bye, Olaf.
 
Hi SWare,

Welcome back.

You can't just set EXCLUSIVE ON and then PACK. EXCLUSIVE has to be on before you open the table.

I suggest you try:

Code:
SET EXCLUSIVE ON
USE GHM_V70
PACK

As for RECCOUNT(), that should give you the number of physical records (deleted and otherwise), regardless of the setting of DELETED. Olaf's suggestion might be the way to solve it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Olaf. The Pack works with the code you provided.

With respect to SET DELETED I forgot that I'm still using an ODBC connection on the tables where I wish to count records (Duh - which explains why the OLEDB command doesn't work). I set Deleted=No in the ODBC connection string and did get a count of all records (deleted and undeleted).

However, there are parts of the code where I want to have Deleted=Yes. Is there an ODBC way to do this other than closing the connection and reopening it with Deleted=Yes in a new connection string? Thanks.
 
Hi Sware,

you could try to Select ... Where NOT Deleted(). But that way you have few control on which table Deleted works. It's best to reopen with Deleted=yes. You might estblish two connections using whichever needed in the situation. And remember reccount() will work regardless of Deleted=No or Yes.

Bye, Olaf.
 
Thanks again Olaf. It looks like two connections is the answer, although I don't understand why there's apparently not a SET DELETED ON [OFF} capability with ODBC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top