Solved

ASP.net C Sharp error

Posted on 2012-03-23
3
492 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

861 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