?
Solved

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

Posted on 2007-08-10
3
Medium Priority
?
287 Views
Last Modified: 2013-11-05
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
0
Comment
Question by:SirReadAlot
  • 2
3 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 19669025
I think what you want is:

ConfigurationManager.ConnectionStrings[""]
0
 

Author Comment

by:SirReadAlot
ID: 19669754
 String strConnectionString = ConfigurationManager.ConnectionStrings["DB_CONN_STRING"];

now it says

Cannot implicitly convert type 'System.Configuration.ConnectionStringSettings' to 'string'      
0
 
LVL 28

Accepted Solution

by:
strickdd earned 2000 total points
ID: 19669873
String strConnectionString = ConfigurationManager.ConnectionStrings["DB_CONN_STRING"].connectionstring;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 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