Web Configure

J

Jim Heavey

When I use the command to retrieve the information, nothing comes back,
what am I doing wrong?

Here is my code...

private string connString =
System.Configuration.ConfigurationSettings.AppSettings["ConnectStr"];


I'm working on a WINDOWS application.
I created a configuration file with the name of "MyProjectName.exe.config".
I loaded the following configuration information into the file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectStr"
value="MyConnectionString />
<add key="DataBase"
value="VideoStore"/>
<add key="DbOwner"
value="jheavey"/>

</appSettings>
</configuration>


Thanks in advance for your assistance!!!!!!!!
 
J

Jim Heavey

Thanks Bill,

But I'm afraid that is not it. In my example, I got rid of my real
connection string and replaced it with something small. In my "real"
program I am using the same "web configure" attributes that I have been
using in a host of web applications.

I think the problem is related to either what I named my configure file as
or where I placed it, but I have not real examples of what it looks like or
how it really works. I think you provided a link to an article that you
wrote on the subject, but again, that article discussed it from a Web
perspective and not a Windows perspective.

My project Name and My Namespace are the same. So naming the configure
file should be "MyNameSpace" or "MyProject".exe.config. Is this correct?

The file which I should create should we an XML file. Is that correct?

If the file does not exists or could not be found, will the
"System.Configuration.ConfigurationSettings.AppSettings" throw and
exception?

The last question is where can I find an example of an actual WINDOWS
config file? I am never too sure about what goes before what and why, so
working from and example will go a long way toward figuring it all out.

Thanks a bunch for taking the time to help and old beginner like me!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top