public DataTable GetStudentGetStudentInfoBySpecifiedPage(int _pageIndex,int _pageSize,out int _totalCount)
{
DataTable dt = new DataTable();
_totalCount = 0;
using (SqlConnection conn = new SqlConnection(connString))
{
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "getStudentInfoByPage";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(new SqlParameter[]
{
new SqlParameter("@pageIndex", _pageIndex),
new SqlParameter("@pageSize", _pageSize)
});
SqlParameter totalCount = new SqlParameter("@totalCount",SqlDbType.Int);
totalCount.Direction = ParameterDirection.Output;
cmd.Parameters.Add(totalCount);
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
_totalCount = (int)cmd.Parameters["@totalCount"].Value;
}
}
return dt;
}
其中pageIndex/pageSize为输入参数,totalCount为输出参数