Solved

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

Posted on 2009-06-27
4
516 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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