
How to connect to FoxPro Free Tables using VB 6
Some time now I'm using the Microsoft Visual Foxpro Driver out of VB with
ADO.
How I did it :
' open connection
Dim strconnect As String
strconnect = "Driver=Microsoft Visual Foxpro Driver;
SourceDB=C:\TESTDBFPATH; SourceType=DBF; Exclusive=No; BackgroundFetch=No;
Collate=Machine; Null=No; Deleted=Yes;"
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open strconnect
cn.Execute "SET REPROCESS TO 10 SECONDS"
' just check some items concerning the provider ...
Dim rs As ADODB.Recordset
Set rs = cn.Execute("SELECT VERSION() as VERSION, SET(""DATE"") as
DATEFORMAT, SET(""HOURS"") as HOURFORMAT FROM TESTTABLE")
Debug.Print rs("VERSION")
Debug.Print rs("DATEFORMAT")
Debug.Print rs("HOURFORMAT")
rs.Close
' open recordset and make modification on first record of table
set rs = new adodb.recordset
dim strsql as string
strsql = "SELECT * FROM TESTTABLE"
rs.open strsql,cn,adopendynamic,adlockpessimistic
if not rs.eof
rs("FIELDNAME1")="TestValue"
rs("FIELDNAME2")="TestValue"
rs.update
endif
Testdbfpath is the path where all the freetables are located.
Testtable is a free table.
You will see that the performance through this ado provider is comparable to
VFP or FPD26. It's nice to feel VFP performance under VB.
Regards,
Donald.
Quote:
> How can I open a FoxPro 6 Free table using VB6 for writing purposes?
> Is there some sample code on the net that I could look at?
> Thanks
> Gerhard