troubleshooting Question

How to read a dbf file from Delphi 5 or above?

Avatar of lamvictor
lamvictor asked on
Microsoft ApplicationsDelphi
7 Comments1 Solution7325 ViewsLast Modified:
I 've tried to use the Class TADOConnection and set the ConnectionString Value to achieve this:

procedure TForm1.FormCreate(Sender: TObject);
var ChannelCount:integer;
tmpStringList: TStringList;
ADOConnection1.ConnectionString := 'Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="CollatingSequence=ASCII;DefaultDir=C:\Documents and Settings\victorltl2\My Documents\Borland Projects\Ant\Data\00_ANT;Deleted=1;Driver={Driver do Microsoft dBase (*.dbf)};DriverId=277;FIL=dBase IV;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=600;SafeTransactions=0;Statistics=0;Threads=3;UID=admin;UserCommitSync=Yes;"';
ADOConnection1.GetTableNames(tmpStringList, True); // this line always has runtime error

My dbf file is located in the directory of 'C:\Documents and Settings\victorltl2\My Documents\Borland Projects\Ant\Data\00_ANT'
The file name is '1018_1_save.ant.dbf'

When the program run to the line of GetTableNames, the error message is :
'Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available.
No work was done.'

What I want is to simply read  the table header and all the content from
the dbf file and store it in TStringList. Except TADOConnection, can I use TQuery to help to do this?
Which one is better?

Any quick and easy sample Delphi code for reference?

Thx for attention.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros