I am trying to write a SQL query that will return a record count to my C#
application. I wrote the following query:
ALTER PROCEDURE up_justification_duplicate
AS
SELECT COUNT(*)
FROM tblJustifications
RETURN COUNT(*)
The table has four records in it. Running the query in the IDE gets me the
following results:
Running dbo."up_justification_duplicate".
-----------
4
No more results.
(1 row(s) returned)
@RETURN_VALUE = 1
Finished running dbo."up_justification_duplicate".
I have tried to extract the count in my application but all I know how to do
is read the return value (always a 1) with a statement like "x =
da.SelectCommand.Parameters[0].Value.ToString();".
How do I get back the correct count, in this case 4?
Any help is greatly appreciated.