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

DBASE(DBF)FILE ACCESSING AND READING&WRITING

Status
Not open for further replies.

fizik72

Programmer
Aug 11, 2003
8
0
0
TR
Hello

How can i read a dbf file using vb?
 
fizik72, welcome to Tek-Tips to get the most from this site you should read this Faq faq222-2244


Try this:

Dim strPath As String
Dim strFileName As String
strPath = "C:\Program Files\Microsoft Office\Office10"
strFileName = "Customer.dbf"
Dim adoConn As New ADODB.Connection
Dim adoRS As New ADODB.Recordset
adoConn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & _
"Dbq=" & strPath 'no backslash

adoRS.Open "Select * From \" & strFileName, adoConn, , , adCmdText
Do Until adoRS.EOF
Debug.Print adoRS.Fields(0).Value
adoRS.MoveNext
Loop
 
by the way you'll need to make a reference to Microsoft ActiveX Data Objects first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top