SqlDataReader无法获取Procedure的Output参数值?
同样的参数去执行一段存储过程
返回类型为DataTable时有值,而返回SqlDataReader时却为空.
public static DataTable ExecuteDataTable(string Text, CommandType commandType, SqlParameter[] para, out int pagecount, out int recordcount)
{
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
{
SqlCommand comm = conn.CreateCommand();
comm.CommandText = Text;
comm.CommandType = commandType;
foreach (SqlParameter p in para)
{
comm.Parameters.Add(p);
}
comm.Parameters.Add( "@pagecount ", SqlDbType.Int);
comm.Parameters.Add( "@RecordCount ", SqlDbType.Int);
comm.Parameters[ "@pagecount "].Direction = ParameterDirection.Output;
comm.Parameters[ "@RecordCount "].Direction = ParameterDirection.Output;
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet dst = new DataSet();
da.Fill(dst);
if (conn.State == ConnectionState.Open)
conn.Close();