数据库连接字符串

 string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection sqlConn = new SqlConnection(connectionString);
sqlConn.Open();
string strSql = "Select * From Capital order by CapitalID";
SqlCommand sqlCmd = new SqlCommand(strSql, sqlConn);
SqlDataReader dtrProvince = sqlCmd.ExecuteReader();

或:
SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSql"]);
Con.Open();
或:
private static string conString = ConfigurationManager.ConnectionStrings["suSoftConString"].ConnectionString;

posted @ 2011-08-08 22:13  风一样的大叔  阅读(151)  评论(0编辑  收藏  举报