• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

Opening a DBF file

I need "detailed" instructions on how to open a dbf file in delphi, and display its contents in a TDBgrid.
I know how to drop a component on a form (TDBGrid, etc), so you can leave that part out. Im talking about the database access & controls compoennts I will need, and the properties to set.

I would like to do this away from the BDE if possible.

IELite
0
IElite
Asked:
IElite
  • 2
  • 2
1 Solution
 
BlackTigerXCommented:
ok, here's one *easy* way

1) run the ODBC Data Source Administrator
  - from the Start, Run type: odbcad32

2) Click Add, select Microsoft Visual Foxpro Driver, click Finish
3) type a name for your data source, select "Free Table Directory", type the path where you DBF file is, click ok

now in Delphi:
4) drop a ADOConnection to your form, double click on it
5) select Microsoft OLE DB Provider for ODBC Drivers, click next
6) in the "Use data source Name" select the one you created in step 3 (if it doesn't show up, click refresh), click OK

7) drop a ADOTable, set the ADOConnection to ADOConnection1
8) drop a DataSource, set the DataSet to ADOTable1
9) drop a DBGrid, set the DataSource to DataSource1
10) set the ADOTable Active to True

done. fiuf...

this was assuming the DBF was a Foxpro table... if is different, you just need to select the right driver in step 2
0
 
IEliteAuthor Commented:
Worked like a charm!

IELite
0
 
BlackTigerXCommented:
great... now, keep in mind that if you want this program to work in other machines, you'll have to do steps 1-3 in that machine... you probably already know that, but just mentioning... now... there's a way to do that programmatically... but that's another question =o)

best regards
0
 
IEliteAuthor Commented:
Nope - I just wanted to open it and see what was in there -------- I didn't have any thing to view the contents.....

thanks!

IElite
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now