日期:2008-10-02 浏览次数:20541 次
else set @SQL='select top '+str(@pageSize) +' * from ( select top '+str(@recordCount - @pageSize * @pageIndex)+' productID,productName, unitPrice from products order by productID desc) TempTable order by productID asc'
private uint pageCount; //总页数
private DataSet GetPageData(uint pageSize, uint pageIndex)
{
string strConn = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand command = new SqlCommand("GetCustomDataPage",conn); //第一个参数为存储过程名
command.CommandType = CommandType.StoredProcedure; //声明命令类型为存储过程
command.Parameters.Add("@pageSize",SqlDbType.Int);
command.Parameters["@pageSize"].Value = pageSize;
command.Parameters.Add("@pageIndex",SqlDbType.Int);
command.Parameters["@pageIndex"].Value = pageIndex;
command.Parameters.Add("@pageCount",SqlDbType.Int);
command.Parameters["@pageCount"].Value = pageCount;
command.Parameters["@pageCount"].Direction = ParameterDirection.Output; //存储过程中的输出参数