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

TQuery, counting, adding and so on

Status
Not open for further replies.

wizzor

Programmer
Aug 29, 2006
23
FI
Hi,
I'm making a rather simple database program, with TurboDelphi. I would like to make some calculations, based on some DB data, provided by a TQuery component over ODBC.

I would like to do the following:
Count rows that were returned by the query.
The only way I found that could do this, is the RecordCount method. Is this "The Way" or is there a better one?
Count rows that have the same value on a column.
Count into one variable, numeric (real) values of one column.

I can figure out several workarounds to the two last ones, using select statements and loops, but I do have the feeling multiple SQL queries are not the most efficient way to go about this.

Anyone care to hint?
 
Now that seems like a very nice situation to plan for.
The system I am building here is multi user, but the program emulates that since it actually uses Access for the data.
As I have stated that eventually Access will not suffice as we grow and enter masses of data into the DB, they are willing to upgrade.
I just have to look up the differences between the alternatives, and make a presentation on it all.
Again when I get spare time. =(

~
Give a man some fire, he will be warm for a day, Set a man on fire, he will be warm for the rest of his life.
 
Additional Question:
Does doing a .RecordCount on the Table itself (linked through a TADOTable) present the same problem possibilities?
Or is that safer since its done on the table and not on what a query returns?

~
Give a man some fire, he will be warm for a day, Set a man on fire, he will be warm for the rest of his life.
 
no, its the same. in fact TADOTable and TADOQuery are using the same dataset structure.

you can easily verify this.

put a TADOConnection component on your form, connect to a mssql server.
take a TADOTable component, set it's Cursorlocation to clUserServer and ask RecordCount, you'll get -1.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Ahhh, thanks dad. =)

~
Give a man some fire, he will be warm for a day, Set a man on fire, he will be warm for the rest of his life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top