I am proficient in ASP and Cold Fusion, but I am very new to .net and am doing the quickstart tutorials on (can anyone recommend a better tutorial?) and I am now doing intro8.aspx.

I notice that the example uses:

I can connect to a DB by putting in a connection string, but keeping the connection string in one place is much better, I presume that is what this line does?
How do I set this property?

I am using webmatrix.

Who is Participating?
eric_duncanConnect With a Mentor Commented:
All .Net applications - windows, console, and web alike, allow configuration information to be stored in a configuration file for ease of use. That being said, to add the connection string information to your web applications, add the following section to your web.config file (which should be located in the root of the web application):

       <add key="PubsString" value="the connection string"/>

Check out the following links for more information:
The line System.Configuration.ConfigurationSettings.AppSettings("PubsString") means that you have stored somehting in the config file or your application (web.config for a web project or app.config for a windows app).
To add such a file, right lcik on your project and Add New Item --> Application Configuration file.

Then you need to add the tags <appSettings> between the <configuration> one and add your key !

  <appSettings file="Server_FO.config">
    <add key="PubsString" value="You connection String here"></add>
Oops ... looks like we were answering at the same time!!
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Two seconds quicker ;-)
Jarodtweiss, will the entries listed in the web.config under the <appSettings> node be processed if you have specified an external file for storage? I didn't think that they would, but I could be wrong.
Yeah they will !
I am using :
  <appSettings file="myFile.xml">

In that case, .NET will :
1. Check in myFile.xml if the given key exist.
    If it is the case, you get that value
2. If the key doesn't exist, it will check in the "standard file" if it exists
    If it is the case, you get that value
3. Otherwise, you get String.Empty

For Hanneman, in that case, myFile.xml must have the following structure :
<?xml version="1.0" encoding="utf-8" ?>
So the "alternative file" will "override" the key of the main file
hannemanAuthor Commented:
hey, i thought there used to be an option for assisted answers?
I was going to split the points because I used both your answers.

I used eric's code, and jarod gave me the method for adding a web.config file (i am that ignorant that i need that kind of info)

Thanks both of you.
All Courses

From novice to tech pro — start learning today.