分页的存储过程的问题

liutingrun 2007-11-28 02:24:50
下面是我的一段(ASP)用于分页的存储过程:
为什么当有记录集时可以正常执行,为什当没有记录集时有如下的提示:
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]第 2 行: '-' 附近有语法错误。

/AdminControl/RelationsSetting.asp,行 133
我的调用该存储过程的ASP语句:
Set objRs=objconn.execute("sp_search_breakpage 'LucyDB_Connection','"&QueryWord&"','"&Line&"','"&CInt(page)&"'")

存储过程:
CREATE PROCEDURE sp_search_breakpage

@tablename varchar(50),

@title varchar(250),

@pagesize int,


@page int

AS

if @tablename='LucyDB_Connection'

begin

declare @ks int

declare @str varchar(200)

set @ks=@pagesize*(@page-1)

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[temp_table91]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

begin

select * into temp_table91 from LucyDB_Connection where
LucyDB_Connection_ConnectionName like '%'+@title+'%' order
by LucyDB_Connection_CreateTime desc

set rowcount @pagesize

set @str='select * from temp_table91 where LucyDB_Connection_ID not in
(select top '+str(@ks)+' LucyDB_Connection_ID from temp_table91)'

execute(@str)

drop table temp_table91

end

end
GO
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
-狙击手- 2007-11-29
  • 打赏
  • 举报
回复
是不是你传过来参数有问题,造成select top N 了呀,这个参数N是负数了
lianhoo 2007-11-29
  • 打赏
  • 举报
回复
帮顶

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧