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

SQLQuery.RecordCount messes up.

Status
Not open for further replies.

Nordlund

Programmer
Jul 17, 2001
458
SE
Hi.
Im trying to implement dbExpress on our application
(Se earlier threads about environment variables and so on).

Has anyone kicked out BDE and replaced it with dbExpress?

dbExpress seems to have a bunch of restrictions like RecordCount. You can't use RecordCount if you have:
Code:
SELECT DISTINCT
or if you are using a question like this:
Code:
SELECT * FROM Table T WHERE T.Field = 'Test'
(I know, the T is unnessecary in this case, but it was an example.).

//Nordlund
 
RecordCount has never reliably worked for the BDE TQuery, so I'm not surprised it doesn't work in the DataExpress components. The best way to get the record count is in a separate query:

Select count(*)
From table T
where t.field := 'Test'

-Dell
 
Yep. I saw that.
And when I dug more into the dbExpress sourcecode, I saw a few more restrictions.

I solved it by creating a descendant of TSQLQuery and overload the Recordcount property with a "while not EOF"-counter.



//Nordlund
 
The problem with a "while not EOF" counter comes when you have a large dataset - it can take some time to do the count. If you're only working with small datasets (couple hundred records as opposed to thousands) it won't be that much of an issue, though.

-Dell
 
Hi.
Yep, It's mainly small datasets. I first try to use the original RecordCount, and if it throws an error, I loop throut the dataset...



//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top