Sunday, March 15, 2009

DataReader problem + OutPutParameter

I was faced this problem yesterday. I search on Google Search engine, but found that we cannot get the OutPutParameter before closing the datareader. So if you want to get the output parameter, you have to close the datareader. After closing datareader, you can got the output parameter. But after closing the datareader you cannot retrieve out data. So if you want to resolve this problme, You have to go through the following :

If you output parament name is @IsExist
SET it with your conditions and query in Stored Procedure
SET @IsExist =1

Then Just add the SELECT statement like :
SELECT @IsExist AS IsExist

Now you can get this variable from Coding(C#) as following
IDataReader = db.Execure(dbCommand);
bool blnIsExist = (Boolean)dr["IsExist"];

Enjoying na:)
Vijay Modi

No comments:

Post a Comment