Solved

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

Posted on 2009-06-27
4
515 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

751 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