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

How to access foxpro database usin

Status
Not open for further replies.

07sprint

Programmer
Sep 18, 2003
25
US
How to access foxpro database using visual basic 6.0.
I get a error message: Unrecognized database format.
 
How are you going about connecting to that database... post some code here.

Also, if there are memo fields in the database, it is much more difficult to do.
 
Hi bjd4jc

Private Sub cmdOpen_Click()

Dim strFilePath As String
strFilePath = "Data Source =D:\PerCap1\PerCap1.dbf;"
Set cn = New ADODB.Connection
cn.CursorLocation = adUseClient
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open strFilePath

'Load frmPerCap

frmPERCAP.Show vbModal

End Sub

There no Memo field in database
 
Here is how you should be connecting to a foxpro database:

Code:
Set cn= New ADODB.Connection
cn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & "DriverID=277;" & "Dbq=d:\PerCap1;"

Then to open the table you want

Code:
Dim rs As ADODB.Recordset

Set rs = New ADODB.recordset
rs.ActiveConnnection = cn
rs.Open "SELECT * FROM PerCap1"

If you had a dbf file called PerCap2.dbf then it would be SELECT * FROM PerCap2. Don't want you to be confused with the directory name being the same as the file name.
 
I'm get Error Message:
Could not find installable ISAM
 
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