Solved

ASP.net C Sharp error

Posted on 2012-03-23
3
490 Views
Last Modified: 2012-03-30
Hi on the line starting '   sqlConn.ConnectionString = ConfigurationManager
I am getting the error "The name ConfigurationManager does not exist in the current contect

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;

namespace CRM_GHB
{
    public partial class Contacts : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void DisplayContacts()
        {
            System.Data.SqlClient.SqlConnection sqlConn = new System.Data.SqlClient.SqlConnection();
            sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings("GHBCRM_TSTConnectionString").ConnectionString;

            try
            {
                sqlConn.Open();
            }
            catch (Exception ex)
            {
                Interaction.MsgBox(ex.Message, "connection failed");
            }
0
Comment
Question by:murbro
3 Comments
 
LVL 18

Accepted Solution

by:
Gary Davis earned 250 total points
ID: 37757157
You need to Add Reference for System.Configuration.

Gary Davis
0
 
LVL 5

Assisted Solution

by:Vishal Kedar
Vishal Kedar earned 250 total points
ID: 37770183
You need to reference System.Configuration.dll in your project as well as the "using" statement.

Namespaces are (sometimes) "split" across assemblies. That means that types in a single namespace are actually in different assemblies.

To determine which assembly a BCL or FCL type is in, look it up on MSDN. If you look at the help for ConfigurationManager, you'll see that it specifies that it's in the System.Configuration assembly by looking near the top at "Assembly". This is the assembly you need to reference from your project
0
 

Author Closing Comment

by:murbro
ID: 37786415
Thanks very much
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

18 Experts available now in Live!

Get 1:1 Help Now