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.OL EDB.4.0;da ta source=c:\\Inetpub\\wwwroo t\\timeshe et\\timesh eet.mdb";
but will not work with:
strConn = ConfigurationSettings.appS ettings("D SN");
and
<configuration>
<appSettings>
<add key="DSN" value="provider=Microsoft. Jet.OLEDB. 4.0;data source=c:\\Inetpub\\wwwroo t\\timeshe et\\timesh eet.mdb" />
</appSettings>
</configuration>
Error I get is:
CS0117: 'System.Configuration.Conf igurationS ettings' does not contain a definition for 'appSettings'
Any ideas?
strConn = "provider=Microsoft.Jet.OL
but will not work with:
strConn = ConfigurationSettings.appS
and
<configuration>
<appSettings>
<add key="DSN" value="provider=Microsoft.
</appSettings>
</configuration>
Error I get is:
CS0117: 'System.Configuration.Conf
Any ideas?
You're working with C# language and it is case-sensitive. Change "appSettings" to "AppSettings" should solve the problem.
try
ConfigurationSettings.AppS ettings.It em("DSN")
ConfigurationSettings.AppS
ASKER
I've tried both these suggestions and still get errors. My current error is:
S0117: 'System.Configuration.Conf igurationS ettings' 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.Conf igurationS ettings.Ap pSettings' denotes a 'property' where a 'method' was expected
When I try it with 'Item' I get this error:
CS0117: 'System.Collections.Specia lized.Name ValueColle ction' does not contain a definition for 'Item'
S0117: 'System.Configuration.Conf
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.Conf
When I try it with 'Item' I get this error:
CS0117: 'System.Collections.Specia
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it, thanks!