Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir
string connectionString =(string)ConfigurationSettings.AppSettings["SanaSoh"];

This line runs correctly on page, but when run in a class it gives me an error. Somebody please give me an idea for app.confing file. I use app.cofing file and give path of my database, but I don't get access to database from within the class.
Please give me an idea how to use database in a class from win.config by using app.config or directly.

Thank you!
Posted
Updated 4-Dec-10 14:23pm
v3
Comments
Manfred Rudolf Bihy 4-Dec-10 16:16pm    
What is the error you are getting?

1 solution

ConfigurationSettings has been obsolete since .NET 2.0 was released. You should be using the ConfigurationManager[^]. Use the ConnectionStrings[^] property to get a database connection string from the app.config file.
 
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