By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,933 Members | 1,586 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,933 IT Pros & Developers. It's quick & easy.

Reading a connection string from the config file

P: n/a
What is the "correct" .NET 2.0 way to do this from within a class

For example, say I have a connection string in app.config or web.config
added using the VS2005 IDE, like so:

<add name="ProjectName.My.MySettings.Connect1"
connectionString="Data Source=x;Initial
Catalog=y;Integrated Security=True"
providerName="System.Data.SqlClient" />

How do I get the above setting in a way that works from both WinForms
and ASP.NET applications? The class is in a DLL which could be called
from either type of client.

The Patterns and Practices Enterprise Library (November CTP for .NET
2.0) uses ConfigurationManager to do it, but MSDN Help says this:

"Using WebConfigurationManager is the preferred way to work with
configuration files related to Web applications; all other methods are
deprecated. For client applications, we recommend that you use the
If Enterprise Library is an implementation of Microsoft best practices,
then why is it using a deprecated method for reading configuration?


Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.