•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 456,524 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,809 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 1458 | Replies: 3
![]() |
I am trying to connect to database using app.config instead of putting the connection settings in each form. Below are the coding that i used. It works in Microsoft Visual Studio 2003. However, it doesn't works in Microsoft Visual Studio 2005. It states that the System.Configuration is obsolete. Does anyone know why and how to solve the problem?
Thank you.
app.config
------------------------------------------------------------------------------------------------------
<?xmlversion="1.0"Üncoding="utf-8"?>
<configuration>
<appSettings>
<addkey="constring"value="data source=Testing; initial catalog=Northwind; Integrated Security=SSPI"/>
</appSettings>
</configuration>
Form
--------------------------------------------------------------------------
Using System.Configuration;
// Setup Connection
string constr = ConfigurationSettings.AppSettings["constring"].ToString();
SqlConnection conn = new SqlConnection(constr);
Thank you.
app.config
------------------------------------------------------------------------------------------------------
<?xmlversion="1.0"Üncoding="utf-8"?>
<configuration>
<appSettings>
<addkey="constring"value="data source=Testing; initial catalog=Northwind; Integrated Security=SSPI"/>
</appSettings>
</configuration>
Form
--------------------------------------------------------------------------
Using System.Configuration;
// Setup Connection
string constr = ConfigurationSettings.AppSettings["constring"].ToString();
SqlConnection conn = new SqlConnection(constr);
•
•
Join Date: Aug 2006
Posts: 57
Reputation:
Rep Power: 3
Solved Threads: 0
hi,
In VS 2005, the ConfigurationSettings is obsolete. try using the following.
Add a reference to System.Configuration,
then in the code,
using System.Configuration;
string connectionstring=ConfigurationManager.AppSettings["Connection"];
and then use the connectionstring variable.
hope this helps.
Regards
Exelio
In VS 2005, the ConfigurationSettings is obsolete. try using the following.
Add a reference to System.Configuration,
then in the code,
using System.Configuration;
string connectionstring=ConfigurationManager.AppSettings["Connection"];
and then use the connectionstring variable.
hope this helps.
Regards
Exelio
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- database connection(select ,insert query) within javascript function (JSP)
- Login Page Database connection to MSAccess (VB.NET)
- Problem with database connection (JSP)
- Database Connection in Visual Studio 2005 (ASP.NET)
- Visual C++, Database connection, please help (C++)
- ASP file with database connection problem (ASP)
- error due to accessing database connection using jsp (JSP)
Other Threads in the C# Forum
- Previous Thread: Regarding regular expressions
- Next Thread: Modify an Object from another variable


Linear Mode