Select count issues

Hi looking for some guidance. I have a routine where I am trying to find a count of records when a field = a certain value. It is only returning a result of one. when I have seeded the DB with at least 2-3 records in my testing. am I missing something in the statement?

dim sql as string
dim c, count as integer

sql = “select count (*) as count from table where attribute = ‘Active’”
dim rs as RecordSet=APP.name.SQLSelect(sql)
count =rs.recordcount
rs.close

DBdisplay.cell(dbdisplay.lastindex,0) ="Total Active: " + str(count)

You are asking the db engine to return a count of the records, then trying to use record count (not supported by all engines) which will be at best 1.

Use count = rs.Field(“count”).IntegerValue which will use the result from the engine instead.

4 Likes

thank you, very much that worked…