Packing FoxPro tables with VB.NET

S

Sajid

Hi! Bill,

Actually I am using the following code to pack my FoxPro tables (Not
Visual FoxPro tables). You know when you delete records from FoxPro
they are just marked for deletion and don't get permanently deleted
unless you issue pack command in FoxPro. So I am using the following
snippet to achieve that. Now the problem is that everything works and
the records actually get deleted but my program hangs on the
cmd.ExecuteNonQuery() command. So can you tell me what am I doing
wrong.


Dim cn As OdbcConnection

cn = New OdbcConnection("Driver={Microsoft Visual FoxPro
Driver};SourceType=DBF;SourceDB=c:\dbfpath;")

Dim mystring As String = "SET EXCLUSIVE ON;PACK Table1"

Dim cmd As OdbcCommand = New OdbcCommand(mystring, cn)

cn.Open()
cmd.ExecuteNonQuery()
cn.Close()


cheers

SY
 
C

Cor Ligthert

Hi Sajid,

I think it is the best to ask this in a Microsoft.public Foxpro newsgroup.

At least Cindy W. who is active there knows too from vb.net.

Cor
 
C

Cindy Winegarden

In news: (e-mail address removed),
Cor Ligthert said:
I think it is the best to ask this in a Microsoft.public Foxpro
newsgroup.

At least Cindy W. who is active there knows too from vb.net.

Hi Cor and Sajid,

The following works for a table named C:\TestPack:

Imports System
Imports System.Data.OleDb

Module Module1

Sub Main()

Try

Dim cn As OleDbConnection

cn = New OleDbConnection("Provider=VFPOLEDB.1;Data Source=C:\;"
& _
"Mode=Share Deny None;Extended Properties="""";User
ID="""";" & _
"Mask Password=False;Cache Authentication=False;Encrypt
Password=False;" & _
"Collating Sequence=MACHINE;Exclusive=ON;DSN=""""")

Dim cmd As OleDbCommand = New OleDbCommand("Pack TestPack", cn)

cn.Open()
cmd.ExecuteNonQuery()
cn.Close()

Catch e As Exception

MsgBox("Exception")

End Try

End Sub

End Module
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top