Solved

problem with configurationsettings.connectionstrings

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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.…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

21 Experts available now in Live!

Get 1:1 Help Now