Link to home
Start Free TrialLog in
Avatar of jack niekerk
jack niekerkFlag for Netherlands

asked on

How to open (read only will do) a Foxpro database in VB6

I did install ODBC from Microsoft for Foxpro,  I need to reed information from sales tables/datafiles created in Foxpro from within VB6 pro
How to setup connection and just plain read from record 1 to record xxxxx
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use ADO.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.Open "Provider=vfpoledb;Data Source=C:\MyDataDirectory\;Collating Sequence=general;"
rs.Open "MyTable", cn, adOpenDynamic, adLockPessimistic, adCmdTable

Open in new window



good morning!

try something like this...

Dim cn as adodb.connection
Dim rs as adodb.recordset

set cn = new adodb.connection
set rs = new adodb.recordset


cn.open "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=YOUR DATABASE PATH;Exclusive=No"

rs.open "Select * from YOURTABLE",cn,adOpenKeyset,adLockOptimistic


i hope give u some idea...



game-master

Avatar of jack niekerk

ASKER

I did create in ODBC a connection to one dbf file  using this

Cn.Open "Driver= Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDb=J:\RUNDER\FOXPRO\;Exclusive=No"
or this
Cn.Open "Provider=Microsoft Visual FoxPro Driver;Data Source=J:\RUNDER\FOXPRO\;Collecting Sequence=general;



will give both ways a run error 3706,
What is the text of the error message, please?
ASKER CERTIFIED SOLUTION
Avatar of tusharkanvinde
tusharkanvinde
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok  tusharkanvinde
RST.Open "Select * from J:\RUNDER\FOXPRO\afilart", Cn, adOpenKeyset, adLockOptimistic  will work
but even when I did give in the open statement the   "data source = J:\RUNDER\FOXPRO\;

  "Select * from afilart   will say file not found and  "Select * from J:\RUNDER\FOXPRO\afilart   will do.
But I can live  that if not to solve
and offcourse I did download  VFP oledb drive
the  "'' use the VFP OLEDB driver instead of the ODBC driver. Data created in VFP7 and later may not be readable by the ODBC """
solved the problem to connect
Are you saying that you had to use the vfpoledb driver that I suggested in the first comment?
I did not now about the existance off this needed link:
http://www.microsoft.com/downloads/details.aspx?familyid=E1A87D8F-2D58-491F-A0FA-95A3289C5FD4&displaylang=en
I wrote back after firts comment i used the default ODBC, and that did not work. (off course my error due to the unkown above to me)
When  tusharkanvinde teached me this link my program worked


Cn.Open "Driver= Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDb=J:\RUNDER\FOXPRO\;Exclusive=No"



u forgot the {} on the "Microsoft Visual FoxPro Driver"


that should work because im using those connection..



game-master