Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update VFP FoxPro Using ADO

Status
Not open for further replies.

McSys

Programmer
Jul 10, 2001
18
US
Am new to trying to update a Visual FoxPro free table (the
*.Dbf file) from VB 6. No problem using the ADO methods to
read the database, but updating issues errors similar to the
other threads I've read in this forum.
From MSDN I understand this to be a "feature" where the
record is "read-only" if the container (*.Dbc file) is not
used.
Unfortunately, my software vendor does not give the DBC,
just the DBF tables.
I REALLY need to get read/write capability to a Visual FoxPro 6 version file. I don't care if I use ADO, RDO, DAO, Oh-NO, or what ever database schema Microsoft has
invented this month.
I will be forever in debt of those forum gurus who can help
me with their knowledege and/or example code.
Thanks in advance!
 
You need to create a static, client-side, optimistic ADO recordset using the open method of the ADODB.recordset object like this:

SET ocn=server.createobject("ADODB.CONNECTION")
ocn.open("DSN=FoxSample")
SET ors=server.createobject("ADODB.RECORDSET")
ors.cursorlocation = adUseClient
Getrs.CursorType = adOpenStatic
Getrs.LockType = adLockOptimistic
ors.OPEN "SELECT * FROM mytable",ocn

This type of recordset is updateable. Just fill in the correct connection string for the connection object.

Check here:
 
The connection string for DBF (free tables) looks like this:

Driver={Microsoft Visual FoxPro Driver};
SourceType=DBF;
SourceDB=\path;
Exclusive=No;

 
Thank you for your response. I looked at the web site you linked with interest.
The code snippet relates to using ADO to access FoxPro with Active Server Pages (ASP). I employed the same logic (I think) in creating a connection and recordset without the
"server." reference but can not get my code to work.
Please pardon my ignorance, I am learning VB while trying to learn how to access VFP files (would rather have root canal).
If you could give me an example without the ASP reference it would be greatly appreciated.
Am beginning to feel like this can't be done in VB...
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top