How can I use the connectionString d开发者_JAVA百科efined 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.
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);
Try playing with ConfigurationManager class. This should do:
string myConnString = ConfigurationManager.ConnectionStrings["myConnStringName"].ConnectionString;
精彩评论