Solved

problem with configurationsettings.connectionstrings

Posted on 2006-07-18
4
219 Views
Last Modified: 2010-05-18
Hi

I have this code:
SqlConnection connection = new SqlConnection(
               ConfigurationSettings.ConnectionStrings[
                   _connect].ConnectionString);

which i have taken off the internet and i get this error

System.Configuration.ConfigurationSettings' does not contain a definition for 'ConnectionStrings'      

Here are my using statements

using System;
using System.Web;
using System.Data.SqlClient;
using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

I dont know how to fix this. I don't know a class that has the property ConfigurationSettings.ConnectionStrings. I only know the webconfig manager

Thanks
0
Comment
Question by:andieje
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 17131362
Try:

    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[_connect].ConnectionString);
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17131465
You also need to add a reference to System.Configuration.dll to the project.

Bob
0
 

Author Comment

by:andieje
ID: 17131535
Hi

I already have a reference to system.cofiguration so that cant be it

I was actually trying to find out what the problem was with the code itself rather than coming up with an alternative. However, I havent realy got time so I will go with the alternative.

Thanks very much for your help
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17131562
Its not an alternative as such. The ConfigurationSettings class is deprecated in .Net 2.0, ConfigurationManager is its replacement.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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