Solved

Avoiding multiple result sets in a SP when using ExecuteReader and datareader

Posted on 2009-06-27
4
513 Views
Last Modified: 2013-12-17
Hello

I have a c# datareader.read method intended to read some rows from just one table in a sql server 2005 DB by means of a stored procedure.

The SP has a final select statement which provides the desired data for the read method, but it has also some other select staments inside which are executed previously to the final select statement which provides the data.

And it seems as if there are not an only result set, but some other ones, one per each select statement in the SP. And this affects the read method.

How can I hide those select statements in the SP distinct from the the final one, in such a way they don't generate result sets which are undesirably readed by the read method?

Thanks in advance,

Juarrero
0
Comment
Question by:juarrero
4 Comments
 
LVL 31

Accepted Solution

by:
RiteshShah earned 63 total points
ID: 24726996
as soon as you execute your command and store your result of SP in dataset, you can refer all your select statement like table[0], table[1] etc. if you have two select statement and you want to have result of only second SELECT, assign table[1] in datareader
0
 
LVL 22

Assisted Solution

by:8080_Diver
8080_Diver earned 62 total points
ID: 24728125
Alternatively, you could have the preceding SELECT statements select into variables of some sort (e.g. individual variables for individual results such as aggregates or, even, in-memory tables) and then work with the variables in the process of completing the SP.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24728391
Why don't you post the stored procedure?  More than likely all the is requires is SET NOCOUNT ON at the start of the Stored Procedure.  But without seeing the Stored Procedure it is impossible to say for sure.
0
 

Author Closing Comment

by:juarrero
ID: 31597209
These two responses have provided me with useful information.

Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question