473,511 Members | 16,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Configuration file read problem

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
4 1871
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2237
by: Ricardo Pereira | last post by:
Hi, I wrote a simple program to test the "out-of-the-box" functionalities of the CMAB (Configuration Management Application Block). After having added 2 values to an hashtable, and having written...
1
1312
by: Mevar | last post by:
Hello to everybody.I have a problem.I'm using an application configuration file to store particular settings.I use a custom Section Handler to read settings and everything work fine if I read my...
7
6564
by: | last post by:
In the beginning we had Ini files. Later we had registery files. Now have xml files and our read-only myapp.config file. My question now, is what is the best way to store and load user and...
7
5971
by: MrNobody | last post by:
I was a Java developer so I'm used to using property files as a means to keep configuration settings for my apps. I'm wondering what options are there with ..NET? Some settings I want to include...
1
1593
by: Paloma García | last post by:
Dear all, I have created personalized configuration sections in my web project following the instructions described in this page...
5
2920
by: Hardy Wang | last post by:
Hi all, I understand, in .Net 2.0 we have little bit different model to read config file from .Net 1.1. Basically I need to use WebConfigurationManager.AppSettings to read from web.config, and...
0
3992
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
6
4783
by: Jeff Hegedus | last post by:
I have a dll that requires some configuration data. I put the configuration data in a custom configuration section in a config file that is loaded in the installation folder of the dll. If I...
8
10204
by: Alberto | last post by:
Can you tell me how to read and modify a value in the app.config file using this class? Thank you very much
0
7138
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
7355
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,...
1
7081
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
5668
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,...
0
4737
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
3225
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...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
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
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.