ASP.NET web.config DB connection string

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?
LVL 2
jonnymccullaghAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ihenryConnect With a Mentor Commented:
this,

strConn = ConfigurationSettings.AppSettings["DSN"];
0
 
ihenryCommented:
You're working with C# language and it is case-sensitive. Change "appSettings" to "AppSettings" should solve the problem.
0
 
RejojohnyCommented:
try
ConfigurationSettings.AppSettings.Item("DSN")
0
 
jonnymccullaghAuthor Commented:
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
 
jonnymccullaghAuthor Commented:
That was it, thanks!
0
All Courses

From novice to tech pro — start learning today.