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

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
 
K

Karl Seguin [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top