473,748 Members | 10,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:
-------------------------------------
<configuratio n>

<configSections >
<sectionGroup name="OurCompan yName">
<section name="OurApplic ationName"
type="System.Co nfiguration.Nam eValueSectionHa ndler"/>
</sectionGroup>
</configSections>

<OurCompanyName >
<OurApplication Name>
<add
name="OurDataba seName"
connectionStrin g="Server=local host;User
ID=xxxx;Passwor d=xxxx;Database =xxxx;Persist Security Info=True;async =true"
providerName="S ystem.Data.SqlC lient" />
</OurApplicationN ame>
</OurCompanyName>
......
<appSettings/>
<connectionStri ngs/>
<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 1288
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 ConfigurationSe ction and ConfigurationEl ement in
System.Configur ation 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.mo onwrote in message news:O4******** ******@TK2MSFTN GP02.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:
-------------------------------------
<configuratio n>

<configSections >
<sectionGroup name="OurCompan yName">
<section name="OurApplic ationName" type="System.Co nfiguration.Nam eValueSectionHa ndler"/>
</sectionGroup>
</configSections>

<OurCompanyName >
<OurApplication Name>
<add
name="OurDataba seName"
connectionStrin g="Server=local host;User ID=xxxx;Passwor d=xxxx;Database =xxxx;Persist
Security Info=True;async =true"
providerName="S ystem.Data.SqlC lient" />
</OurApplicationN ame>
</OurCompanyName>
.....
<appSettings/>
<connectionStri ngs/>
<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
2475
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 machine config, this was necessary as our web site has 4 environments and the database server has a different name in each. Since the upgrade the applications can't read the strings in the
1
1796
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 DB (no problem with that). I try to save DB connection string in web.config file, as described in MSDN 'Declaring and Accessing Section Groups' article. I think this is optimal way/place to store global variables accessible from any part of...
7
1383
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 handle a string like this in asp.net 2.0? thanks!
5
1596
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 process, I am utilizing our SCM tool and things are working just fine. I make a change on my machine, commit it, and update the QA machine and the change is immediately visible in the web app there. The irritating thing is that I often make changes...
10
9468
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 ConfigurationErrorException whenever I do the following: 1. Modify and save the section in code using the System.Configuration.Configuration.Save(). 2. Refresh teh section using ConfigurationManager.RefreshSection 3. Encrypt the section,...
2
1841
by: =?Utf-8?B?U2JhdGNodQ==?= | last post by:
How will i read connection strings in all web.config files in one particualr machine?
8
1653
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 can imgaine that I can get one config file per buisness library. What is teh best way and where to store configuration files ? Should I get only one with everything in and located in a particular common
10
2059
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 my apps can use the same connection strings. That is supposed to be how it's done, no? Instead of the web.config being in c:\inetpub\wwwroot\myApp\web.config, I have it in c:\inetpub\wwwroot\web.config. However, I get an "Object reference not...
4
1154
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
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.