Opening a DBF file

Posted on 2005-04-08
Last Modified: 2010-04-05
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.

Question by:IElite
    LVL 13

    Accepted Solution

    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

    Author Comment

    Worked like a charm!

    LVL 13

    Expert Comment

    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

    Author Comment

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



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now