4

Been trying to figure out, but I can't.

I execute a Stored Procedure via SqlCommand and the SqlDatareader object that is returned doesn't give me the results, however, I can see them if a explore the object in the debugger. here's an image of what I'm talking about:

See the "Result view" row

In the Result View row it says "Enumeration yielded no results" but in the path:

base -> base -> ResultView -> [0] -> Non-Public members -> _values -> [0],1,[2],[3] the results are shown.

Anyone has an idea how to get them?

This is the code I'm using to get and specific column:

if (dataReader.Read())
{
   ProjectFolderId = dataReader["ItemID"].ToString();
}

but the if is returning false.

1
  • Having same issue. Any solution ? Commented Aug 7, 2017 at 14:37

1 Answer 1

10

You need to be careful: a reader can only be consumed once. By having the data visible in the preview window, it is entirely likely you've consumed that data accidentally in the debugger, and it is no longer available.

Make sure it is not visible/expanded in a debugger preview window, and try again.

The _values shown is just the legacy/remains of the last row that was successfully read.

Sign up to request clarification or add additional context in comments.

3 Comments

How I can make them not visible? Btw, I executed the query without the Stored Procedure (direct in the CommandText property and then ExecuteSelect) and now is working. I believe is something odd with the proccess using Stored Procedures, what you think?
@equasar I doubt it relates to stored procedures - beyond setting the command-type, the API is identical; usually, you need to electively click to expand an enumeration, because the IDE knows that many are non-repeatable. Did you maybe click to expand it?
You rock, @MarcGravell. I can't believe the debugger consumes the data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.