473,508 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to query App.config?

Here's my App.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="customers">
<section name="test1"
type="System.Configuration.DictionarySectionHandle r" />
<section name="test2"
type="System.Configuration.DictionarySectionHandle r" />
</sectionGroup>
</configSections>

<appSettings>
<add key="ConnectionString" value="some value here" />
</appSettings>

<customers>
<test1>
<add key="CustCode" value="0001" />
<add key="FtpHost" value="ftp://xxx.com" />
<add key="FtpAccount" value="user1" />
<add key="FtpPassword" value="password1" />
<add key="Active" value="Y" />
</test1>
<test2>
<add key="CustCode" value="0002" />
<add key="FtpHost" value="ftp://yyy.com" />
<add key="FtpAccount" value="user2" />
<add key="FtpPassword" value="password2" />
<add key="Active" value="Y" />
</test2>
</customers>
</configuration>

If I know the 'CustCode' value (such as "0001"), how can I retrieve all the
other values for 'test1'?
I appreciate your help! Thank you.
Aug 17 '07 #1
1 1747

"Eve" <Ev*@discussions.microsoft.comwrote in message
news:39**********************************@microsof t.com...

<snipped>
If I know the 'CustCode' value (such as "0001"), how can I retrieve all
the
other values for 'test1'?
I appreciate your help! Thank you.
You use the ConfigurationManger namespace that comes with .Net Framework
2.0, or you install the Application Blocks for .Net Framework 1.1 which uses
the ConfigurationSettings namespace.

This link talks about ConfigurationManager for .Net Framework 2.0.

http://www.eggheadcafe.com/articles/20060622.asp

If you using .Net Framework 2.0, then the only thing you're doing is
downloading the examples and code on how to use ConfigurationManager, which
there will be examples in VB and C#.Net. There is nothing to install.

http://www.google.com/search?hl=en&q...=Google+Search

If you are using .Net Framework 1.1, then you have to download and install
the Enterprise Library for Application Blocks. which will have examples in
VB and C# .Net too.

With .NET FW 2.0, you just set reference to the dll for Configuration
Manager, and for .NET FW 1.0, you have to determine which dll in the
Enterprise Library you must use and set reference to it or them. There is
nothing to compile as the dll(s) have the code that's needed. You just use
the dll(s).

In either case for 2.0 or 1.0 with Application Blocks examples in VB or
C#.Net, you will see one example on how to pull the elements of the XML
App.Config file into your program so that you can use the values of the
elements.

It's a piece of cake, and it should be no problem for you to do what you
want. You can also use Google to see the how-to(s) as well.

Aug 18 '07 #2

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

Similar topics

10
1959
by: ensnare | last post by:
Hey everyone -- I currently have a table friends: member_id (int 10), connect_id (int 10), active (char 1) which contains friend relationships. When active is set to 1, the relationship...
2
1692
by: ensnare | last post by:
This query is running REAL slow ... like 1.2 secs ... any ideas on how I could optimize it? Perhaps my indexes are incorrect? $this->query = "SELECT m.username as username, e.title as title,...
2
1391
by: ensnare | last post by:
This query is running REAL slow ... like 1.2 secs ... any ideas on how I could optimize it? Perhaps my indexes are incorrect? $this->query = "SELECT m.username as username, e.title as title,...
1
3101
by: Sean C. | last post by:
Helpful folks, I have recently migrated our test server, which runs Win NT 4, from V7.2 FP11 to V8.1.3. Just about everything works wondefully, except I am having major problems getting the...
9
23689
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the...
0
7328
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
7388
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...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5631
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,...
1
5055
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...
0
4709
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...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
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...

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.