Solved

ASP.NET web.config DB connection string

Posted on 2004-09-03
5
426 Views
Last Modified: 2008-02-26
Newbie question: I've got a page that works with the following:
strConn = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\Inetpub\\wwwroot\\timesheet\\timesheet.mdb";

but will not work with:
strConn = ConfigurationSettings.appSettings("DSN");

and
<configuration>
    <appSettings>
        <add key="DSN" value="provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\Inetpub\\wwwroot\\timesheet\\timesheet.mdb" />
    </appSettings>
</configuration>

Error I get is:
 CS0117: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'appSettings'

Any ideas?
0
Comment
Question by:jonnymccullagh
  • 2
  • 2
5 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 11979403
You're working with C# language and it is case-sensitive. Change "appSettings" to "AppSettings" should solve the problem.
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 11987443
try
ConfigurationSettings.AppSettings.Item("DSN")
0
 
LVL 2

Author Comment

by:jonnymccullagh
ID: 11987921
I've tried both these suggestions and still get errors. My current error is:
S0117: 'System.Configuration.ConfigurationSettings' does not contain a definition for 'appSettings'
This makes me think that machine.config may be being checked for appSettings rather than web.config. Am i wrong?

When I changed appSettings to AppSettings I get the following error:
 CS0118: 'System.Configuration.ConfigurationSettings.AppSettings' denotes a 'property' where a 'method' was expected

When I try it with 'Item' I get this error:
CS0117: 'System.Collections.Specialized.NameValueCollection' does not contain a definition for 'Item'
0
 
LVL 20

Accepted Solution

by:
ihenry earned 50 total points
ID: 11987928
this,

strConn = ConfigurationSettings.AppSettings["DSN"];
0
 
LVL 2

Author Comment

by:jonnymccullagh
ID: 11987969
That was it, thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question