How to get connection string from web.config in public class?

  • Thread starter Thread starter staeri
  • Start date Start date
S

staeri

I have a public class in a vb file placed in the app_code directory
where I would like to put generic db functions.

I was hoping to get the connection string from web.config with the
following code but it doesn't work:

Public Shared ConnectionString As String =
ConfigurationSettings.AppSettings("ConnectionString")

It says that "this method is obsolete". Is there any other way to make
it work?

Regards,

S
 
In 2.0, the class has been obsoleted by the ConfigurationManager. You can
learn more from:
http://www.devx.com/dotnet/Article/27562

It takes advantage of the new connectionStrings section in the web.config
and more.

You can continue to use the obsoleted class, but future versions of the
framework might not support those objects/methods.

Karl
 
Back
Top