sql return a query result to a variable

It´s possible return a query result to a variable instead a datareader. For ex. in some cases i need return only a sum or two.
Who is Participating?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
for a single value: yes:
ExecuteScalar() returns an object with the single value.

as soon as you need more values/rows, either use a stored procedure with adequate output parameters, or do use the datareader (or dataset/datatable)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.