Solved

ASP.NET web.config DB connection string

Posted on 2004-09-03
5
425 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now