+ Start a Discussion
dke01dke01 

Dynamic Count()

How do I do this:

 

Integer totalRows = (Database.query(myQuery ))

 

 Now I get a error cannot convert sObject to Integer

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Database.query returns a list of sobjects.

 

Sounds like you should be using Database.countQuery. 

All Answers

bob_buzzardbob_buzzard

Database.query returns a list of sobjects.

 

Sounds like you should be using Database.countQuery. 

This was selected as the best answer
dke01dke01
Perfect thank you, not sure why I did not see that in the API