数据库关闭另一种方法
原来一直用.close(),今天发新一个新的方法就是using
在尝试的过程中发现一个疑惑
就是查寻数据的时候例子这样写的
DataTable dt = new DataTable(); cmd = new SqlCommand(sql, Getconn()); using (str = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { dt.Load(str); } return dt; DataTable dt = new DataTable(); using (cmd = new SqlCommand(sql, Getconn())) { str = cmd.ExecuteReader(); dt.Load(str); } return dt;