
复制publicstatic SqlDataReader ExecuteReader(CommandType cmdType,闭问
string cmdText, params SqlParameter[] cmdParms) { SqlCommand cmd = new SqlCommand(); SqlConnection conn = new SqlConnection(CONN_STRING); // we use a try/catch here because if the method throws an exception we want to // close the connection throw code, because no datareader will exist, hence the // commandBehaviour.CloseConnection will notwork try { PrepareCommand(cmd, conn, null, cmdType, cmdText, cmdParms); SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); cmd.Parameters.Clear(); return rdr; } catch { conn.Close(); throw; } } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.
(责任编辑:IT科技)