Click here to Skip to main content
15,905,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
pls send me solution for

------> is not accessable due to its protection level

i declared sqlconnection sqlcon= new sqlconnection();
sqlcon.connectionstring = configurationManager.AppSettings["xxx"].Tostring();

in one class

and me accessing from another class creating object of sqlconnection class

but it is giving above error .........................>
Posted

 
Share this answer
 
There's actually quite a lot wrong with that code, however...

1. Use properties as accessors to variables, you should not be accessing member variables directly outside of the scope in which they're defined
2. Define the property with the appropriate access modifier to scope it's accessibility. i.e., private, protected, internal, public etc.

Hopefully that'll get you going, if not Google c# access modifier[^] for more information
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900