Solved

ASP.NET web.config DB connection string

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

16 Experts available now in Live!

Get 1:1 Help Now