Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.NET web.config DB connection string

Posted on 2004-09-03
5
Medium Priority
?
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

598 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