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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use ADO to connect to a FoxPro DBF file

Status
Not open for further replies.

EZEason

Programmer
Dec 11, 2000
213
US
I have a FoxPro file on a CD that I need to search and copy the results to the hard drive. I'm using VB 6 and ADO for now. I would like to run an ADO sql statement to Insert the results to temp table that I have on the hard drive. What I do not know is how to search a .dbf file with ADO and save the results. Can anyone help me?

What doesn't kill you makes you stronger.
 
You might be better off with dao - as I think it has a foxpro setting. Otherwise you'll probably have to go the odbc route. Try using Microsoft Data Link (or using the ado control) to build you a connection string
 
This is where I got the connection string:


Go here to get the OLE provider unless you have Visual FoxPro 7.0 or 8.0:


This will give you a start:

Dim CONN As ADODB.Connection
Dim RS As ADODB.Recordset
Dim i As Integer
Private Sub Command1_Click()
Set CONN = New ADODB.Connection
Set RS = New ADODB.Recordset
CONN.Open "Provider=vfpoledb;" & _
"Data Source=C:\rutgers\trans.dbf;" & _
"Mode=ReadWrite|Share Deny None;" & _
"Collating Sequence=MACHINE;" & _
"Password=''"
RS.Open "SELECT Key from Trans", CONN, adOpenDynamic, adLockOptimistic, adCmdText
Do Until RS.EOF
MsgBox RS.Fields(0)
RS.MoveNext
Loop
RS.Close
CONN.Close
Set RS = Nothing
Set CONN = Nothing
End Sub

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top