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

using DBF files with Delphi

Status
Not open for further replies.

Gigatech

Programmer
Jul 12, 2000
80
CR
Hi, I'm a D7 user. I need to connect my app to a Foxpro 2.6 app. I open the database files (*.DBF) but Delphi don't load the index files (CDX). I'm using the Visual Fox Pro ODBC driver because I didn't found the Fox 2.6 ODBC driver.
Do you have this driver? any idea?

Thanks
 
Do you mean your using an app written in FoxPro and want to open that or a FoxPro database you want to open with Delphi app?

If its the latter, you can use the BDE and FoxPro driver (in D7Pro).

Set up a [tt]tDataSource[/tt] and a [tt]tTable[/tt], ensuring the name is set in [tt]tTable.TableName[/tt], and the [tt]tTable.TableType[/tt] is [tt]tTable.ttDefault[/tt]. [tt]IndexFiles[/tt] can be set to the same name if you wish to your CDX , but this automatically links to the index file (particularly if you have [tt]tTable.TableType = ttFoxPro[/tt]).
The spec for FoxPro had the index file containing multiple indexes (Order Bags) in a file with the same name as the DBF (ie MyFile.DBF uses MyFile.CDX - and MyFile.DBT for memos).

You can also link to the DBF (albeit much slower than the BDE), without the CDX index, using the ADO driver (as you appear to be doing) and the ODBC dBase Files (Microsoft dBase driver) in [tt]UserDSN[/tt] of the [tt]Microsoft ODBC Administrator[/tt].
In that case, try the following.....
[ul]
[li]Set the Provider to [TT]Microsoft OLE DB Provider for ODBC Drivers[/TT][/li]
[li]Set up a [tt]tADOconnection[/tt], with the connection using [tt]dBase Files[/tt] as the data source name.
Make sure you set [tt]tADOconnection.DefaultDatabase[/tt]to point to the database path[/li]
[li]Add a [tt]tDataSource[/tt][/li]
[li]Add a [tt]tADOquery[/tt][/li]
[li]Link your [tt]tADOquery.DataSource[/tt] to your [tt]tDatasource[/tt]name[/li]
[li]in your [tt]tADOquery.SQL[/tt][/li] set up the SQL to open your DBF file, and create your own index fields eg:
[tt]SELECT lastname,firstname,birthdate FROM MYFILE ORDER BY (lastname);[/tt]
This last step is the important one - it sets up your indexing and opens the correct file.
[li]You can test a lot of the SQL using the Database Desktop - [tt]File->New->SQL File[/tt].
Type in your SQL and test it out by running it: [tt]Run->SQL->Run SQL[/tt][/li]
[/ul]

Theres quite a good tutorial at

Hope thats some help.

Chris ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top