By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,641 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,641 IT Pros & Developers. It's quick & easy.

Configuration file read problem

P: n/a
I need to use a configuration file to set the connection string for the ado
data connector in my project, but I'm having trouble reading the config
file.

My config file contains the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings> <add key="ConnectionString" value="server=localhost;user
id=root;password=pw;database=aceinventory;pooling= false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.config where ACE_Inventory is the name of
the project's exe file and is located in the project's bin folder.

I'm using the following line to read the file:
sInventoryConnection =
System.Configuration.ConfigurationSettings.AppSett ings("ConnectionString")

Unfortunately, this does not read the config file.

I'd sure appreciate any advice.

Thanks, Steve Enzer
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try ACE_Inventory.exe.config

"Steve Enzer" <no****@nospam.com> wrote in message
news:ua*************@TK2MSFTNGP15.phx.gbl...
I need to use a configuration file to set the connection string for the ado
data connector in my project, but I'm having trouble reading the config
file.

My config file contains the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings> <add key="ConnectionString" value="server=localhost;user
id=root;password=pw;database=aceinventory;pooling= false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.config where ACE_Inventory is the name of
the project's exe file and is located in the project's bin folder.

I'm using the following line to read the file:
sInventoryConnection =
System.Configuration.ConfigurationSettings.AppSett ings("ConnectionString")

Unfortunately, this does not read the config file.

I'd sure appreciate any advice.

Thanks, Steve Enzer

Nov 21 '05 #2

P: n/a
I've tried that, as that is what the Microsoft documentation says to do.
But as soon as I run the app in debug mode, Visual Studio immediately
deletes the file.

"Marina" <so*****@nospam.com> wrote in message
news:Oe***************@tk2msftngp13.phx.gbl...
Try ACE_Inventory.exe.config

"Steve Enzer" <no****@nospam.com> wrote in message
news:ua*************@TK2MSFTNGP15.phx.gbl...
I need to use a configuration file to set the connection string for the
ado data connector in my project, but I'm having trouble reading the
config file.

My config file contains the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings> <add key="ConnectionString" value="server=localhost;user
id=root;password=pw;database=aceinventory;pooling= false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.config where ACE_Inventory is the name of
the project's exe file and is located in the project's bin folder.

I'm using the following line to read the file:
sInventoryConnection =
System.Configuration.ConfigurationSettings.AppSett ings("ConnectionString")

Unfortunately, this does not read the config file.

I'd sure appreciate any advice.

Thanks, Steve Enzer


Nov 21 '05 #3

P: n/a
Steve,

try this. Add a new item to your project and select the Application
Configuration. Don't change the default name app.config. Now open this
config file and copy/paste from your original into this new one.

Now, when you build your project it will automatically create the
project.exe.config file for you and place it in the bin folder!

HTH, Phil

"Steve Enzer" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I've tried that, as that is what the Microsoft documentation says to do.
But as soon as I run the app in debug mode, Visual Studio immediately
deletes the file.

"Marina" <so*****@nospam.com> wrote in message
news:Oe***************@tk2msftngp13.phx.gbl...
Try ACE_Inventory.exe.config

"Steve Enzer" <no****@nospam.com> wrote in message
news:ua*************@TK2MSFTNGP15.phx.gbl...
I need to use a configuration file to set the connection string for the
ado data connector in my project, but I'm having trouble reading the
config file.

My config file contains the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings> <add key="ConnectionString" value="server=localhost;user
id=root;password=pw;database=aceinventory;pooling= false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.config where ACE_Inventory is the name
of the project's exe file and is located in the project's bin folder.

I'm using the following line to read the file:
sInventoryConnection =
System.Configuration.ConfigurationSettings.AppSett ings("ConnectionString")

Unfortunately, this does not read the config file.

I'd sure appreciate any advice.

Thanks, Steve Enzer



Nov 21 '05 #4

P: n/a
Phil, this finally worked. I spent a lot of time going thru Microsoft's
help files and it's too bad they weren't more explicit about this topic.

Much thanks,
Steve

"Phil G." <Ph**@nospam.com> wrote in message
news:dg*********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
Steve,

try this. Add a new item to your project and select the Application
Configuration. Don't change the default name app.config. Now open this
config file and copy/paste from your original into this new one.

Now, when you build your project it will automatically create the
project.exe.config file for you and place it in the bin folder!

HTH, Phil

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.