Solved

problem with configurationsettings.connectionstrings

Posted on 2006-07-18
4
220 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
[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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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