Hi,
Thank for your example, will test it out.
However, I using free table without the .dbc file,
can I just open the dbf file and pack it ?
>>>>>Any way for ADO 2.5/2.6 to pack dbf file ?
>>>>
>>>>Chatter is an odd place for a question like this.
>>>>
>>>>Perhaps the following KB article with help:
http://support.microsoft.com/?kbid=234756, "HOWTO: Pack a Table Through the Visual FoxPro ODBC Driver (VFPODBC.dll)."
>>
>>>Thank for the advise, but I using VB6 with ADO,
>>>hence the KB articles does not applied.
>>
>>The KB article shows the SQL command which packs the table - "SET EXCLUSIVE ON;PACK TableName". In other words, you can send two commands at onece by separating them with a semicolon. I'm going to see if it works when accessing VFP data either by ODBC or OLE DB. Generally, OLE DB does everything that ODBC did, and then adds some new functionality.
>
>The following worked for me in VB6:
>Sub Main()
>
> Dim cnConn As ADODB.Connection
> Dim cmdCommand As ADODB.Command
>
> Set cnConn = New ADODB.Connection
> cnConn.Open "User ID=;DSN=;" & _
> "Cache Authentication=False;Data Source=""C:\MY DOCUMENTS\VISUAL FOXPRO PROJECTS\TEST.DBC"";" & _
> "Password=;Provider=""VFPOLEDB.1"";Collating Sequence=MACHINE;Mask Password=False;Mode=Share Deny None;" & _
> "Extended Properties=;Encrypt Password=False;Exclusive='ON'"
>
> Set cmdCommand = New ADODB.Command
> cmdCommand.CommandType = adCmdText
> cmdCommand.CommandText = "PACK TestPack.dbf"
> Set cmdCommand.ActiveConnection = cnConn
> cmdCommand.Execute
>
>End Sub
Best Regards
Virusim