473,320 Members | 2,202 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,320 software developers and data experts.

ConfigurationSettings.ConnectionStrings("Personal" ).ConnectionString does not work

I am a user of the ConfigurationSettings.AppSettings("KeyName") in
asp.net 1.1 so after reading about the new ConnectionStrings collection
in "Intoducing Microsoft ASP.NET 2.0 by Dino Esposito on page 137 I
excitedly started a demo project to try it out. I am getting an error
in the editor. It's telling me that ConnectionStrings is not a member
of System.Configuration.ConfigurationSettings. What am I doing wrong?

Dave

Nov 28 '05 #1
3 6153
Dear Dave,

ConfigurationManager Class
===================
One important new configuration-related class is the ConfigurationManager
class, which provides seamless programmatic access to configuration files and
configuration sections. Using the methods and properties of this class, you
can open configuration files and retrieve configuration sections from within
your application.

It gives Quick access to the appSettings and connectionStrings sections of
the current application's default configuration file, which you access
through properties such as AppSettings and ConnectionStrings

Note: The ASP.NET process account needs sufficient permissions to be able to
read and write into the specified configuration file.

For simplicity, to run the tryouts, enable Integrated Windows authentication
through IIS and enable impersonation at the Web site level using the
following configuration settings under the <system.web> element in the
web.config file.

<identity impersonate="true"/>

One of the Property = ConnectionStrings

This property gets the appropriate data from the <ConnectionStrings> section
of the current application's configuration file.
Retrieving Connection Strings
===================
..NET 2.0 introduces a new configuration section called <connectionStrings>
that lets you store connection strings securely in a .NET application.

These Steps will show you how to read the connection string that is stored
inside the <connectionStrings> section in a web.config file.

Step :1
--------------
First, you need to prepare your web.config file. For example, here's a
portion of a web.config that contains a <connectionString> entry.

<connectionStrings>

<add name="pubs"
connectionString="localhost;integrated
security=true;database=pubs;" />

</connectionStrings>

The following code retrieves that connection string from the web.config file
using the ConnectionStrings property of the ConfigurationManager class.

ConfigurationManager.ConnectionStrings["pubs"].ConnectionString

or

You can simply output the Connection String for example:

Response.Write("Connection String:"
+ ConfigurationManager. ConnectionStrings["pubs"].ConnectionString);

Bye
Venkat_KL

Nov 28 '05 #2
It seems the book code wasn't updated from beta 1.

The easiest way to do this is to import System.WebConfiguration and
use:

Dim s As String =
WebConfigurationManager.ConnectionStrings("foo").C onnectionString

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 27 Nov 2005 21:50:40 -0800, "Dave" <da**@palfery.com> wrote:
I am a user of the ConfigurationSettings.AppSettings("KeyName") in
asp.net 1.1 so after reading about the new ConnectionStrings collection
in "Intoducing Microsoft ASP.NET 2.0 by Dino Esposito on page 137 I
excitedly started a demo project to try it out. I am getting an error
in the editor. It's telling me that ConnectionStrings is not a member
of System.Configuration.ConfigurationSettings. What am I doing wrong?

Dave


Nov 28 '05 #3
Thanks all. I am suprised I did not find this question already posted.
Thanks again

Nov 29 '05 #4

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

Similar topics

1
by: VB Programmer | last post by:
When my users login I want them to be able to change some of their personal info in a db. I want to use a detailsview control for this. How can I get the detailsview to only pull up the record...
2
by: Tor Inge Rislaa | last post by:
I am prompted to implement the syntax below to be able to monitor the error on the remote server trough my browser (client). I can't seem to find where to place the code in my web.config file to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.