数据库连接字符串
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 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;