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

Web.Config - retrieving DB connection strings held in specific section

Hi

Bit confused about how to read a connection string from my web.config...I
need to hold this data in a particular section (v2.0 specific).

Extract from web.config:
-------------------------------------
<configuration>

<configSections>
<sectionGroup name="OurCompanyName">
<section name="OurApplicationName"
type="System.Configuration.NameValueSectionHandler "/>
</sectionGroup>
</configSections>

<OurCompanyName>
<OurApplicationName>
<add
name="OurDatabaseName"
connectionString="Server=localhost;User
ID=xxxx;Password=xxxx;Database=xxxx;Persist Security Info=True;async=true"
providerName="System.Data.SqlClient" />
</OurApplicationName>
</OurCompanyName>
......
<appSettings/>
<connectionStrings/>
<system.web/>
</configuration>
-------------------------------------

I just can't get the code right for extracting this information....

Many thanks in advance

Griff

Oct 11 '06 #1
2 1276
I just can't get the code right for extracting this information....

What is that you didn't get write?
Handler? Are you looking at 1.1?

In 2.0, look into ConfigurationSection and ConfigurationElement in
System.Configuration namespace.
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujinionline.com
http://eduzine.edujinionline.com
-----------------------------------------
Oct 11 '06 #2
Karl Seguin has a very good tutorial on custom configuration sections at :

http://openmymind.net/Configuration/index.html

It'll help you do what you want to do.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Griff" <ho*****@the.moonwrote in message news:O4**************@TK2MSFTNGP02.phx.gbl...
Hi

Bit confused about how to read a connection string from my web.config...I need to hold this data
in a particular section (v2.0 specific).

Extract from web.config:
-------------------------------------
<configuration>

<configSections>
<sectionGroup name="OurCompanyName">
<section name="OurApplicationName" type="System.Configuration.NameValueSectionHandler "/>
</sectionGroup>
</configSections>

<OurCompanyName>
<OurApplicationName>
<add
name="OurDatabaseName"
connectionString="Server=localhost;User ID=xxxx;Password=xxxx;Database=xxxx;Persist
Security Info=True;async=true"
providerName="System.Data.SqlClient" />
</OurApplicationName>
</OurCompanyName>
.....
<appSettings/>
<connectionStrings/>
<system.web/>
</configuration>
-------------------------------------

I just can't get the code right for extracting this information....

Many thanks in advance

Griff

Oct 11 '06 #3

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

Similar topics

6
by: Mikey_Doc | last post by:
Hi We are running cms 2002, Framework 1.0 with Visual studio 2002. We have just upgraded to Framework 1.1 and visual studio 2003. All of our database connection strings are stored within the...
1
by: DS | last post by:
Hi all, Will appreciate if someone can help me with this problem. I am using VS 2003 on Win2000, sp 4. 2GB RAM. Session data is stored on DB on another machine in network. Can connect to the...
7
by: Brian Henry | last post by:
I've never stored a program specific connection string in the web.config file before, is there any information on how to store it there and access it from the app and what would be the best way to...
5
by: Mike Kelly | last post by:
Hi. I've got a standard setup with a web app (ASP.NET 2.0) that I develop on my machine, deploy to a QA server for testing, and then on to a PROD environment. To facilitate the deployment...
10
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
2
by: =?Utf-8?B?U2JhdGNodQ==?= | last post by:
How will i read connection strings in all web.config files in one particualr machine?
8
by: =?Utf-8?B?Y2FsZGVyYXJh?= | last post by:
Dear all, I am building a set of libraries working in a n tiers architecture Some of those libraries use common configuration settings like the database connection string and some others. I...
10
by: eagle | last post by:
I have a web.config in my application that contains the connection strings to all my datasources. I want to move these connection strings to another web config up the folder hierarchy so that all...
4
by: Raymon Du | last post by:
Hi, I am getting the following exception every time I modified web.config, the only way to fix it is to recycle application pool or restart IIS, but I don't want to do that all the times. TIA
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.