The name 'ConnectionSettings' does not exist in the current context

Hi experts,
how do i correct the above error.

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Text;

namespace DirectorySweeper
{
    class Program
    {
        static void Main(string[] args)
        {
            String strConnectionString = ConnectionSettings.AppSettings["DB_CONN_STRING"];================this line
            SqlConnection conn = new SqlConnection(strConnectionString);

            try
            {
                conn.Open();
                Console.WriteLine("Connection Open Successfully");
            }
            catch (Exception exp)
            {
                throw new Exception(exp.ToString());
            }
            finally
            {
                conn.Close();
            }
        }
    }
}


thanks
SirReadAlotAsked:
Who is Participating?
 
strickddConnect With a Mentor Commented:
String strConnectionString = ConfigurationManager.ConnectionStrings["DB_CONN_STRING"].connectionstring;
0
 
strickddCommented:
I think what you want is:

ConfigurationManager.ConnectionStrings[""]
0
 
SirReadAlotAuthor Commented:
 String strConnectionString = ConfigurationManager.ConnectionStrings["DB_CONN_STRING"];

now it says

Cannot implicitly convert type 'System.Configuration.ConnectionStringSettings' to 'string'      
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.