1

I am using .NET Framework 4.5 in Visual Studio 2012 and read its help on http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.connection.aspx. But in my code I cant get access to this property - it is inaccessible to a copy of SqlDataReader. How can I get readers SqlConnection ?

5
  • 1
    Can you share your code?? As it would help to understnd your problem better!!! Commented Aug 24, 2013 at 14:55
  • 1
    Why do you need to access it? The SqlCommand you have used to get the SqlDataReader has a public property Connection. Commented Aug 24, 2013 at 14:58
  • I need it because I dont want pass two arguments to the method instead of one. Commented Aug 24, 2013 at 15:05
  • 1
    Why do you pass a SqlDataReader to another method at all? You should consume it where you executed it. Commented Aug 24, 2013 at 15:07
  • To reduce number of cycles in one method. I give him to other method and there already in a cycle I read out fields. Commented Aug 24, 2013 at 15:08

1 Answer 1

3

You can't access it because this property is protected:

protected SqlConnection Connection { get; }

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

Comments

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.