开发者

C# ConnectionString

开发者 https://www.devze.com 2023-02-15 01:11 出处:网络
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

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消