查询语句为:sql="select distinct 产品.物品名称 as 名称,库存.合库存量 from 库存 inner join 产品 on 库存.产品ID=产品.产品ID order by 产品.产品ID asc" 
你的存储过程后几句的格式为如下:
insert into @indextable(nid) select 产品.产品ID from 库存 inner join 产品 on 库存.产品ID=产品.产品ID order by 产品.产品ID desc
select O.名称 from 库存 O,@indextable t where O.产品.产品ID=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id
上面的select O.名称 from 库存 O join 产品 on 库存.产品ID=产品.产品ID ,@indextable t where O.产品.产品ID=t.nid对吗,改为select O.名称 from 库存 O ,@indextable t where O.产品.产品ID=t.nid对吗,请作答。能不能给一个完整的答案。

解决方案 »

  1.   

    webdiyer的存储过程rrr如下:
    CREATE procedure rrr 
    (@pagesize int,  
    @pageindex int,  
    @docount bit)  
    as  
    set nocount on  
    if(@docount=1)  
      
       select count(newsid) from artitle 
    else  
    begin  
    declare @indextable table(id int identity(1,1),nid int)  
    declare @PageLowerBound int  
    declare @PageUpperBound int  
    set @PageLowerBound=(@pageindex-1)*@pagesize  
    set @PageUpperBound=@PageLowerBound+@pagesize  
    set rowcount @PageUpperBound  
       insert into @indextable(nid) select newsid from artitle  order by dateandtime desc  
    select O.newsid,O.title, O.typename,O.dateandtime from artitle O,@indextable t where O.newsid=t.nid  
    and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id  
    end  
    set nocount off
    GO
    上面的查询句为:select count(newsid) from artitle ,我想改为:sql="select distinct 产品.物品名称 as 名称,库存.合库存量 from 库存 inner join 产品 on 库存.产品ID=产品.产品ID order by 产品.产品ID asc"
      

  2.   

    set rowcount @PageUpperBound  ?这个写法是否有误
      

  3.   

    首先声明一点:这个问题和AspNetPager分页控件毫无关系,分页存储过程只是用来获取分页数据的,分页控件并不是必须要存储过程才能用!因为从你的情况看,没有标识列,而且只有全部字段组合起来才能成为主键,所以要用我那样的使用临时表或表变量的存储过程,得创建一个带标识列的表变量或临时表,把所有字段都插入到这个表中,然后根据标识列来获取要分页的数据,获取数据的方法没有多少区别,只是不需要再从其它表中获取,只需从刚创建的临时表或表变量获取即可,因为所有字段都已插入这个表中了。
      

  4.   

    我的存储过程工具创建的存储过程中的表变量或临时表中就有标识列,就是那个标识为identity的列。