?
Solved

problem with configurationsettings.connectionstrings

Posted on 2006-07-18
4
Medium Priority
?
224 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

771 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