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

Custom values in app.config

Hi,

I am building an appliaction that will do some processing on specified
databases. I would like to specify in a configuration file what databases to
process.There is not a fixed number of databases so the number can vary.

Ideal (If i just could figure out how to do this) would be if i could get a
string array containing my values from the configuration file that I could
loop through.

Any suggestions on how to do this ?

Regards

Niclas Lindblom
Nov 20 '05 #1
2 911
Add a new item to your component and select "Application configuration".
Edit this file so it looks like

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Database1" value="my first database"/>
<add key="Database2" value="my second database"/>
<add key="SomeOtherSetting" value="my other stuff"/>
</appSettings>
</configuration>

Add these imports

Imports System.Configuration
Imports System.Collections.Specialized

And use code like this

Dim sDatabaseCollection As NameValueCollection =
ConfigurationSettings.AppSettings()

Dim sDatabase As String
For Each sDatabase In sDatabaseCollection.AllKeys
If sDatabase.StartsWith("Database") Then
MessageBox.Show(sDatabaseCollection(sDatabase))
End If
Next

"MS Newsgroups" <no****@nospam.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am building an appliaction that will do some processing on specified
databases. I would like to specify in a configuration file what databases to process.There is not a fixed number of databases so the number can vary.

Ideal (If i just could figure out how to do this) would be if i could get a string array containing my values from the configuration file that I could
loop through.

Any suggestions on how to do this ?

Regards

Niclas Lindblom

Nov 20 '05 #2
Cool,

Thats the way to do it !

Thanks for helping out

Niclas
"Adrian Forbes [ASP MVP]" <so***@noemail.zzz> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
Add a new item to your component and select "Application configuration".
Edit this file so it looks like

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Database1" value="my first database"/>
<add key="Database2" value="my second database"/>
<add key="SomeOtherSetting" value="my other stuff"/>
</appSettings>
</configuration>

Add these imports

Imports System.Configuration
Imports System.Collections.Specialized

And use code like this

Dim sDatabaseCollection As NameValueCollection =
ConfigurationSettings.AppSettings()

Dim sDatabase As String
For Each sDatabase In sDatabaseCollection.AllKeys
If sDatabase.StartsWith("Database") Then
MessageBox.Show(sDatabaseCollection(sDatabase))
End If
Next

"MS Newsgroups" <no****@nospam.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am building an appliaction that will do some processing on specified
databases. I would like to specify in a configuration file what databases
to
process.There is not a fixed number of databases so the number can vary.

Ideal (If i just could figure out how to do this) would be if i could
get a
string array containing my values from the configuration file that I

could loop through.

Any suggestions on how to do this ?

Regards

Niclas Lindblom


Nov 20 '05 #3

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

Similar topics

8
by: Geopsaros | last post by:
Hi! I have created a custom trace Listener class, called "DBTraceListener" it works fine when i add it manually in code : (eg. Trace.listeners.add(new DBTraceListener("myDBListener",...
7
by: Ken Allen | last post by:
I have a .net client/server application using remoting, and I cannot get the custom exception class to pass from the server to the client. The custom exception is derived from ApplicationException...
1
by: Hans [DiaGraphIT] | last post by:
Hi! I have problem with passing data to custom action. I don't know what wrong I'm doing. I'm trying to follow the steps in the walkthrough: "Passing Data to a Custom Action" ...
2
by: Jarod_24 | last post by:
I Created a .config file for my Web application and named it "Settings.config" The file contains some settings for the application, including a connection string to a database. But i don't...
4
by: Nick Gilbert | last post by:
Hi, I would like the ability to store the configuration settings for all versions of my site in a single web.config file by using different sections. Eg: <siteConfig> <machine name="XENON">...
3
by: Mads Brydegaard | last post by:
Hi, I have created a custom Config handler for reading a custom config section in my .config file(s) It works very well! I have placed a web.config in my root directory and then I use sub...
1
by: Tumurbaatar S. | last post by:
Hi! In old ASP I used Application collection to store configuration settings like ADO connection string. In .NET, it seems, the preferred method is using Web.config file. Yes? If I'm right then...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
6
by: Shimon Sim | last post by:
Hi I am working on application that need to hold custom user information - Last and first name, email, some other domain related information. I used to create Base class for all my pages. The base...
6
by: Tabi | last post by:
Hi, I want to create a custom section in my web.config that can hold my custom values. I created a section in web.config as written below. <configSections> <section name="myCustomSection"...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.