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

Record Count from Query

Status
Not open for further replies.

JimReiley

MIS
Dec 10, 2004
58
US
When I run a query in Delphi, I need to know how many rows are affected, i.e. returned, from the query. The rowseffected propery always returns a -1 and it shouldn't.

Thanks.
 
Are you using PvQuery or TQuery or something else?

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
Custom VB and Btrieve development.
 
From the Borland docs on TQuery (which PvQuery inherits from):
Inspect RowsAffected to determine how many rows were updated or deleted by the last query operation. If no rows were updated or deleted, RowsAffected has a value of zero. RowsAffected will have a value of –1 if the execution of the SQL statement could not be executed due to an error condition. This latter situation would typically follow the raising of an exception.

Unless you're doing an insert, update, or delete query, I would expect this value to be useless.


Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
Custom VB and Btrieve development.
 
So if it's worthless, how do you know how many records are returned on a select statement?
 
You might look at RecordCount.. It'll depend on the cursor but it might help.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
Custom VB and Btrieve development.
 
After the SQL.Exec is given, you can't get a record count, pervasive tells me you can't do that on a closed dataset. Not being used to pervasive's flavor or sql, I find a lot of gotcha's with this stuff.
 
I found the answer. Since I am doing a select, ExecSql is not the way to go. Use the Open command. Then the values of rowsaffected will be real.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top