代码改变世界

c#读取web.config连接字符串

2008-11-14 13:10  Iron  阅读(352)  评论(0编辑  收藏  举报
string myDataString =
    ConfigurationManager.ConnectionStrings["AdvWorks"].ConnectionString;
System.Data.SqlClient.SqlConnection sqlConn =
    new System.Data.SqlClient.SqlConnection(myDataString);
sqlConn.Open();