0

How can I use the connectionString defined in APP.Config in datasource wizard? I can do it in a web application easily but I can't do it in non web application program.

1
  • You can copy temporary the .config file in some app_data/ directory. Commented Mar 7, 2011 at 9:24

2 Answers 2

5

You need to use the bellow syntax to retrive the connection string from app.config

string conStr = ConfigurationManager.ConnectionStrings["NorthwindConnection"].ConnectionString;

Then use the bellow syntax.Oh!first of all you need to add using System.Configuration; name space

 Connection = new SqlConnection(conStr);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer, but how can I use it in DataSource configuration wizard, in "which data connection should you application use to connecto to dabase" part, my mean is in design not in run time
1

Try playing with ConfigurationManager class. This should do:

string myConnString = ConfigurationManager.ConnectionStrings["myConnStringName"].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.