Link to home
Start Free TrialLog in
Avatar of Wayne29
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
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi Wayne29,

You can get the output parameters, however you can only do so after you have closed the datareader!

Tim Cottee
Wayne29,

If you really need them first, consider making the stored procedure return mutiple resultsets, using

Select @OutputParam1,@OutputParam2

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
Avatar of Wayne29
Wayne29

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
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wayne29

ASKER

Thanks Tim. You are correct.
Wayne