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

Opening Visual Foxpro dbf file in Visual Basic

Status
Not open for further replies.

bebbo

Programmer
Dec 5, 2000
621
GB
When I try to open a dbf file in Visual Basic, I get the message 'Cannot locate the
requested Xbase memo file'.

Does anyone know how I can open a dbf file in VB ???
 
How about creating a .dll in VFP to do what you want and then add it to your VB project?

Dave Dardinger
 
Bebbo,

If your table(dbf) has 1 or more fields of type MEMO, there will be a 2nd file with an fpt extension that houses this information. This file will need to present in the same directory as the dbf. Jon Hawkins
 
Option Explicit
Dim cn As New rdoConnection
Dim rs As rdoResultset
Dim SQL As String

' Add a RDO in the refer.
' Using a DSN-less connection to open a free table
cn.Connect = "SourceType=DBF;" & "SourceDB=D:\MasterDB\Bb;" & "Driver={Microsoft Visual FoxPro Driver}"

cn.CursorDriver = rdUseOdbc
cn.EstablishConnection "rdDriverNoPrompt"

SQL = "select * from bbone1" 'this should be a free table
Set rs = cn.OpenResultset(SQL, rdOpenKeyset, rdConcurRowVer)

rs.MoveFirst
Do Until rs.EOF
Set itmX = ListView1.ListItems.Add()
itmX.Text = rs(0)
itmX.SubItems(1) = rs(1)
itmX.SubItems(2) = rs(2)
itmX.SubItems(3) = rs(3)
itmX.SubItems(4) = rs(4)
itmX.SubItems(5) = rs(5)
itmX.SubItems(6) = rs(6)
itmX.SubItems(7) = rs(7)
itmX.SubItems(8) = rs(8)
itmX.SubItems(9) = rs(9)
DoEvents
rs.MoveNext
Loop

' Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top