web.config配置
<appSettings>
<add key="ConnectionString" value="server=.;database=testdb;uid=sa;pwd=sa1"/>
</appSettings>
// 获取连接字符串
string _connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
SqlConnection _conn = new SqlConnection(_connectionString);
string sql = "Select * from user ";
//SqlCommand _cmd = new SqlCommand(sql, _conn);
_conn.Open();
//int rr = _cmd.ExecuteNonQuery();
SqlDataAdapter _cmd = new SqlDataAdapter(sql, _conn);
_cmd.Dispose();
_conn.Close();