Link to home
Start Free TrialLog in
Avatar of jonnymccullagh
jonnymccullagh

asked on

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?
Avatar of ihenry
ihenry

You're working with C# language and it is case-sensitive. Change "appSettings" to "AppSettings" should solve the problem.
try
ConfigurationSettings.AppSettings.Item("DSN")
Avatar of jonnymccullagh

ASKER

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'
ASKER CERTIFIED SOLUTION
Avatar of ihenry
ihenry

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was it, thanks!