Hi Ken,
You haven't said whether your data is "free" tables or part of a DBC.
Accessing data is different from "starting FoxPro." You can copy the data to
a computer where FoxPro is not installed and access the data via ODBC
without starting FoxPro or running any programs/executables.
If you're using a Database Container (DBC) you can run code automatically
when accessing data by putting it in a stored procedure and calling it by an
insert/update/delete trigger. You can't do this in VFP6 DBC's by merely
opening the database.
Later versions of FoxPro have "database events" where you can write code to
run when a table is opened but these tables and DBCs are not compaible with
ODBC - you'd need to use OLE DB.
Did you know that you can pack a table from VB6? The following VB6 code
worked for me for the file C:\TestPack.dbf.
'-- ----------------------------------------
Public Sub Main()
' First delete all the records
Set conn1 = New ADODB.Connection
conn1.Open _
"Provider=VfpOleDB.1;" & _
"Data Source=C:\;"
Set cmd1 = New ADODB.Command
cmd1.CommandType = adCmdText
cmd1.ActiveConnection = conn1
cmd1.CommandText = "Delete From TestPack"
cmd1.Execute
conn1.Close
Set conn1 = Nothing
' Now Pack the table to shrink its size
Set conn1 = New ADODB.Connection
conn1.Open _
"Provider=VfpOleDB.1;" & _
"Data Source=C:\;"
Set cmd1 = New ADODB.Command
cmd1.CommandType = adCmdText
Set cmd1.ActiveConnection = conn1
cmd1.CommandText = "Set Exclusive On"
cmd1.Execute
cmd1.CommandText = "Pack TestPack.dbf"
cmd1.Execute
conn1.Close
End Sub
'-- ----------------------------------------
Finally, why do you feel you need to pack the Fox tables, especially every
time an app is run? Unless the tables are extremely large, most Fox
developers just leave the deleted records in the tables, or at best do
housekeeping during off hours like over the weekend.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
***@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
Post by Ken DI am using FoxPro 6 and I have written a program to PACK tables that have
records marked for deletion. I want the PRG file to run at the startup of
foxpro, and I want to know if connecting to a foxpro database via ODBC and
ADO connection string will make foxpro run the PRG, or will I need to call
the PRG explicitly.
I am running VB 6.O, FoxPro 6.0 on Windows XP.