473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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("ConnectionStrin g")

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

Regards,

S

Feb 22 '06 #1
1 1575
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

--
http://www.openmymind.net/

<st****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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("ConnectionStrin g")

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

Regards,

S

Feb 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Charlie | last post by:
Hi: I'm storing my dB connection in web.config file. Since it will be easily read by opening file, what is a good way to secure it? Thanks, Charlie
4
by: Jeff | last post by:
I have a main project which references several DLLs. Each DLL will access the same database as the main project. I'm storing the connection string within the main project's "web.config" file, so...
19
by: Jaime Stuardo | last post by:
Hi all.. I have created a business logic component that is used from my ASP.NET webform. It works, but connection string to the database is hard coded, as in this method : public DataSet...
5
by: Dave Johnson | last post by:
Working on Asp.net with access database backend,a serious Question in the Class design phase, for accessing the database; Which is Better to make a Connection Class that handles all the ADO...
3
by: ad | last post by:
I have a web application which refer a class library project. The web application have a web.config and the class library project have a app.config. They all have connection string defined in...
5
by: mlg1906 | last post by:
I'm developing an intranet site in ASP.NET 2.0 but I can't seem to connect to the DB from within my code. I've created a .vb class that houses a private Connection() that other functions within the...
6
by: Mike | last post by:
We are intermitantly receiving this error on our website. ExecuteReader requires an open and available Connection. The connection's current state is connecting. Following is the code from the Load...
2
by: Jon Paal | last post by:
..net 2.0 can't retrieve connection string from web.config, always returns error message -- what's missing ?? ======web.config ========= <appSettings> <connectionStrings> <add...
1
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.