Get row count in SQL?

N1c0_ds

Active Member
Licensed User
I need to get the total row count for the "Main" table in my SQL DB but can't find out how to get it.

I made a touch scrollbar for Gecko that gets 12 entries from an offset determined by the Mousedown coordinates and displays them with FDrawString.

This is how I get the OFFSET value for my query:
(Y position from the scrollbar top) / (Scrollbar height) * (SQL table's row count)

Then I do this to display 12 results I will show with Drawstring on my Form (The background image is the UI)

SQLCmd.CommandText="SELECT Name FROM Main LIMIT 12 OFFSET "
SQLCmd.ExecuteTable("tblList",0)
 

Ricky D

Well-Known Member
Licensed User
Longtime User
what count?

Do you want a count of all entries?

If so then use

SQLCmd.CommandText="SELECT Count(Name) From Main"

it will be returned in reader's getvalue(0) item after you set the reader to SQLCmd's executereader method

if you're going to apply a Where clause then add it like this

SQLCmd.CommandText="SELECT Count(Name) From Main Where <fieldname>='something or other'"

regards, Ricky
 
Top