Solved

problem with configurationsettings.connectionstrings

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

724 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