0

I am not able to use

String connectionString = ConfigurationManager.ConnectionStrings["DevBackup"].ConnectionString;

I am getting error 'The name 'ConfigurationManager' does not exist in the current context'
I have used namespaces

using System.Data.SqlClient;
using System.Data.Sql;

what should be done..?? Am I missing something..??

3 Answers 3

5

You need to add a reference to the System.Configuration assembly to your project, and then a using System.Configuration; statement to your app.

Sign up to request clarification or add additional context in comments.

Comments

1

Do you also have System.Configuration in your namespaces?

Comments

1

For ASP.NET, System.Web.Configuration is the correct namespace to use:

using System.Web.Configuration;
String connectionString = WebConfigurationManager.ConnectionStrings["DevBackup"].ConnectionString;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.