use MyLove
go
create proc usp_GetHoues
@PageSize int,
@PageIndex int
as
begin
select * from (select ROW_NUMBER() over(order by id) as nid,
* from Houes ) as nHoues where nid between (@PageIndex - 1) * @PageSize + 1 and @PageSize * @PageIndex
end
go
为什么运行部了!SQL存储分页

解决方案 »

  1.   

    为什么光报 ‘必须声明标量变量 "@PageIndex"。’  这错呢!!!!!!!!!!!!!!求解释 求更正
      

  2.   

    public int GetRowCount(string table, string cond, string[] strparam, object[] strval)
           {           string query = string.Format("Select count(*) From {0} {1}", table, cond);
               DataSet ds = db.GetDataSet(query, strparam, strval);
               if (ds != null)
               {
                   if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                   {
                       return Galsun.Common.Utils.StrToInt(ds.Tables[0].Rows[0][0].ToString(), 0);
                   }
               }
               return 0;       }
           public DataSet GetinfoList(string table, int pageindex, int pagesize, string orderFid, string Conditions, string[] strparam, object[] strval)
           {           string query = "Select top {0} * From "
                   + "(Select *,ROW_NUMBER() OVER(ORDER BY {2}) as RowNum From {4} {3}) as newTable "
                   + "Where (RowNum > {1} )";
               query = string.Format(query, pagesize, (pageindex - 1) * pagesize, orderFid, Conditions, table);           //string query = "Select top {0} * From {1} {2} and id not in(Select top {3} id From {1} {2} Order by {4}) Order by {4}";
               //query = string.Format(query, rowcount, table, Conditions, (rowpage - 1) * rowcount + 1, orderFid);
               return db.GetDataSet(query, strparam, strval);       }
      

  3.   

    哥 。你写的是VS的页面代码啊 、我要的是SQL语句啊我已经创建了啊分页的 就是运行有错   哥哥哥哥哥哥哥啊!
      

  4.   


    那要看你是怎么调用的了,你发sql语句给我,我也只能验证他是否正确,不可能知道你的.cs代码是否正确吧
      

  5.   

    create  procedure  Proc_purchaseorderform
     @Rowspage int,
     @Torowspage int
     as
    select *from purchaseorderform where po_id  in
    (
     select top (@Rowspage) po_id from purchaseorderform  where po_id in
     (select top (@Torowspage) po_id from purchaseorderform order by po_id )
      order by po_id desc
     )
     order by po_id
     go 照着这个写  也是分页的存储过程
      

  6.   

    Quote: 引用 6 楼 xiaoxinxin1128 的回复:

    create  procedure  Proc_purchaseorderform
     @Rowspage int,
     @Torowspage int
     as
    select *from purchaseorderform where po_id  in
    (
     select top (@Rowspage) po_id from purchaseorderform  where po_id in
     (select top (@Torowspage) po_id from purchaseorderform order by po_id )
      order by po_id desc
     )
     order by po_id
     go 这个我试了还是报那个‘必须声明标量变量 "@Rowspage"。’
      

  7.   

    这个不是在里面声明着吗?  @Rowspage