473,748 Members | 11,145 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" ?>
<configuratio n>
<appSettings> <add key="Connection String" value="server=l ocalhost;user
id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.c onfig 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:
sInventoryConne ction =
System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")

Unfortunately, this does not read the config file.

I'd sure appreciate any advice.

Thanks, Steve Enzer
Nov 21 '05 #1
4 1891
Try ACE_Inventory.e xe.config

"Steve Enzer" <no****@nospam. com> wrote in message
news:ua******** *****@TK2MSFTNG P15.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" ?>
<configuratio n>
<appSettings> <add key="Connection String" value="server=l ocalhost;user
id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.c onfig 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:
sInventoryConne ction =
System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")

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******** *******@tk2msft ngp13.phx.gbl.. .
Try ACE_Inventory.e xe.config

"Steve Enzer" <no****@nospam. com> wrote in message
news:ua******** *****@TK2MSFTNG P15.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" ?>
<configuratio n>
<appSettings> <add key="Connection String" value="server=l ocalhost;user
id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.c onfig 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:
sInventoryConne ction =
System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")

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.con fig file for you and place it in the bin folder!

HTH, Phil

"Steve Enzer" <no****@nospam. com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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******** *******@tk2msft ngp13.phx.gbl.. .
Try ACE_Inventory.e xe.config

"Steve Enzer" <no****@nospam. com> wrote in message
news:ua******** *****@TK2MSFTNG P15.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" ?>
<configuratio n>
<appSettings> <add key="Connection String" value="server=l ocalhost;user
id=root;passwor d=pw;database=a ceinventory;poo ling=false"/>
</appSettings>
</configuration>

The file is named ACE_Inventory.c onfig 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:
sInventoryConne ction =
System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")

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.co m> 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.con fig 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
2250
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 that hashtable (using the XmlHashtableSectionHandler) to an XML file (using the XmlFileStorage) I try to read back the hashtable with those values. I am adding a "string" value (with a string key) and a "double" value (also with a string key) to...
1
1325
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 settings.If I add some settings to the file and I read the configuration file again I can see only the previous setting.To read the setting added I must exit from the application and run it again.Anyone know why it happens?I've read that...
7
6578
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 machine specific settings for a .NET program? And what classes, or code do we have to do this in C#? I don't think that using the myapp.config is the best choice to store since the file might be read-only if the program is started from a CD ROM, or...
7
5987
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 are like a root directory for a target program on the user's machine my app uses, which they would be prompted to supply at startup. Normally the registry is used for this but I'd rather not use the registry if possible. Isn't there some kind of...
1
1610
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconDeclaringCustomConfigurationSections.asp The problem is that I using the same code and I get the error "Object reference not set to an instance of an object" in the line where I try to read the first parameter (in the page...
5
2934
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 ConfigurationManager.AppSettings to read from Windows Application config. Here is my question, I have a class library project which will be referenced by both Web and Windows Application in different projects, I need to read config setting inside...
0
4004
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, but my department has a couple of web servers of our own that are part of my organization's domain. I am trying to read LDAP information on my organization's domain controller from a web application on one of my department's servers. I have been...
6
4810
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 install the dll to the same directory as the exe which uses it, everything works as expected but if I load the dll in any other directory, I get the following error... 2007-02-04 16:36:51,171 DEBUG CentrifugeBHO.CentrifugeBHO - dllPath =...
8
10219
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
8828
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
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8241
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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
4599
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...
1
3309
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 we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
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.