使用SqlHelper时“阅读器关闭时read的尝试无效”的解决方法
?
原SqlHelper类中ExecuteReader方法体为:
public static SqlDataReader ExecuteReader(string sqlString, params SqlParameter[] sqlParams) { SqlConnection conn = new SqlConnection(ConnString); SqlCommand cmd = new SqlCommand(); try { PrepareCommand(conn, cmd, sqlString, sqlParams); SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); cmd.Parameters.Clear(); return rdr; } catch { return null; } }
?
?