Wayne29
asked on
ASP.NET with sql 2k
I have a sql server stored procedure which returns a resultset and also has out params. I want to execute this SP from .Net. But I have a choice of using ExecuteReader method or ExecuteNonQuery method. If I execute with ExecuteReader method I get resultset only. If I execute with ExecuteNonQuery method, I get out param values.
Does anyone know how to execute SP only once and get resultset and out param values?
Your help as before is much appreciated.
Regards
Wayne
Does anyone know how to execute SP only once and get resultset and out param values?
Your help as before is much appreciated.
Regards
Wayne
Wayne29,
If you really need them first, consider making the stored procedure return mutiple resultsets, using
Select @OutputParam1,@OutputParam 2
Select ...... your existing statement
You can then use read the datareader for the first resultset to get the "output" parameters and then use datareader.nextresult() to advance the datareader to the second resultset for the other records.
Tim
If you really need them first, consider making the stored procedure return mutiple resultsets, using
Select @OutputParam1,@OutputParam
Select ...... your existing statement
You can then use read the datareader for the first resultset to get the "output" parameters and then use datareader.nextresult() to advance the datareader to the second resultset for the other records.
Tim
ASKER
Hi Tom,
Thanks for reply.
My Question is, I should be able to get RESULTSET (interms of reader / dataset anything is OK) along with OUT values from SP.
If possible, can i have pseudo code / code snippet.
Thanks
Wayne
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Tim. You are correct.
Wayne
Wayne
You can get the output parameters, however you can only do so after you have closed the datareader!
Tim Cottee