一个我没有解决了的问题,请高手指点一下!

ygghost 2004-06-07 07:27:45
我写了一个存储过程,语法是成功的。

主要是用了游标在数据库之间循环取数据,然后插到临时表(#t),以用作查询或者

其他操作。现在的问题是,我在web页面上对这个结果集进行分页的话,执行到

rs.AbsolutePage = q_page这句就报错。
==========================================================================
ADODB.Recordset 错误 '800a0cb3'

当前记录集不支持书签。这可能是提供程序或选定的游标类型的限制。
==========================================================================

如果不分页的话就可以了,也就是说我生成的这个记录集不支持rs.AbsolutePage 和

rs.recordcount这些属性。asp的方法我都试过了,我想问题可能出现在存储过程的

游标上。这个pro可能有点长,但是就是游标那几句,请高手给看下问题怎么办?
...全文
74 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ygghost 2004-06-07
  • 打赏
  • 举报
回复
其实我在贴出问题的同时就查到了答案,rs.CursorLocation=3

就是这个了,

果然是高手啊,十分佩服

我开始一直以为是游标定义的有问题呢!
zjcxc 2004-06-07
  • 打赏
  • 举报
回复
如果你是用command对象来调用存储过程
则不要用 set rs=cmd.execute 的形式

而改为:
rs.CursorLocation=3
rs.open cmd 的形式
zjcxc 2004-06-07
  • 打赏
  • 举报
回复
'如果你用asp+vbscript,则类似这样打开记录集

<%
'数据库连接字符串
iConc = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=用户名;Password=密码;Initial Catalog=数据库名;Data Source=SQL服务器名"
Set iRe =Server.CreateObject("ADODB.Recordset")
With iRe
.CursorLocation = 3 'adUseClient '一定要这个
.Open "exec Fmisdj 参数", iConc, 1,1
End With

'分页处理

iRe.Close
Set iRe = Nothing
%>
zjcxc 2004-06-07
  • 打赏
  • 举报
回复
既然不分页正常,那就证明这个问题跟你的存储过程没有什么关系.

问题应该是出在你的记录集打开方式上.
ygghost 2004-06-07
  • 打赏
  • 举报
回复
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


ALTER PROCEDURE Fmisdj
@Yhdm varchar(20),
@dwdh varchar(20),
@summary varchar(50),
@fromtime datetime,
@totime datetime
AS

declare @Ssql varchar(4096),
@SDBName varchar(64),
@DDBName varchar(64),
@strfromtime varchar(10),
@strtotime varchar(10)
set @strfromtime=left(Convert(varchar(30),@fromtime,120),10)
set @strtotime=left(Convert(varchar(30),@totime,120),10)

CREATE TABLE [dbo].[#t] (
[dwdh] [varchar] (12) NULL,
[dwmc] [varchar] (128) NULL,
[nd] [varchar] (20) NULL,
[billid] [int] NULL,
[ttime] [datetime] NULL ,
[summary] [varchar] (60) NULL ,
[UniformCode] [varchar] (46) NULL ,
[typename] [varchar] (40) NULL ,
[subtypename] [varchar] (40) NULL ,
[postname] [varchar] (40) NULL ,
[yhdm] [varchar] (40) NULL ,)
ON [PRIMARY]
select @SDBName = 'fmis_share'
select @DDBName = 'fmis_share'
select @Ssql = 'declare fmis_db cursor for '---这里声明了游标
+ 'select databasename,dh,mc from ['+@DDBName+'].[dbo].[xtdw] where databasename is not null'
--print(@Ssql)
exec(@Ssql)
declare @vDBname varchar(60), @vDh varchar(12), @vMc varchar(128)
open fmis_db
fetch next from fmis_db into @vDBname, @vDh, @vMc
WHILE @@FETCH_STATUS = 0
begin
select @vDBname = ltrim(rtrim(@vDBname))
select @vDh = ltrim(rtrim(@vDh))
select @vMc = ltrim(rtrim(@vMc))
if (exists(select * from master.dbo.sysdatabases where name = @vDBname)) and (@vDh <> 'MAIN')
begin
set @Ssql = 'use ['+@vDBname+']'
+ ' insert into [dbo].[#t](dwdh,dwmc,nd,billid,ttime,summary,UniformCode,typename,subtypename,postname,yhdm)'
+ ' select '''+@vDh+''' as dwdh, '''+@vMc+''' as dwmc,''2003'' as nd,'
+ ' a.billid,a.ttime,a.summary,b.typename+ '' ''+Cast(a.code1 as varchar(4)) as UniformCode ,'
+ ' b.typename,c.typename as subtypename,f.postname,e.yhdm'
+ ' from xtdj2003 a join xtbilltype b on a.typeid=b.typeid join xtbilltype1 c on a.typeid=c.typeid and a.typeid1=c.typeid1'
+ ' join xtdjpost2003 d on a.billid=d.billid join xtpostop e on d.postid=e.postid join xtpost f on d.postid=f.postid'
+ ' where d.poststate=0 and e.yhdm='''+@Yhdm+''''
+ ' union '
+ ' select '''+@vDh+''' as dwdh, '''+@vMc+''' as dwmc,''2004'' as nd,'
+ ' a.billid,a.ttime,a.summary,b.typename+ '' ''+Cast(a.code1 as varchar(4)) as UniformCode ,'
+ ' b.typename,c.typename as subtypename,f.postname,e.yhdm'
+ ' from xtdj2004 a join xtbilltype b on a.typeid=b.typeid join xtbilltype1 c on a.typeid=c.typeid and a.typeid1=c.typeid1'
+ ' join xtdjpost2004 d on a.billid=d.billid join xtpostop e on d.postid=e.postid join xtpost f on d.postid=f.postid'
+ ' where d.poststate=0 and e.yhdm='''+@Yhdm+''' order by a.billid '
print (@Ssql)
exec(@Ssql)
end

fetch next from fmis_db into @vDBname, @vDh, @vMc
end
CLOSE fmis_db
DEALLOCATE fmis_db

if @dwdh=''
if @summary=''
if @fromtime=''
begin
set @Ssql='select * from #t order by ttime desc'
exec(@Ssql)
end
else
begin
set @Ssql='select * from #t and ttime < '''+@strtotime+''' and ttime >'''+@strfromtime+''' order by ttime desc'
exec(@Ssql)
end

else
if @fromtime=''
begin
set @Ssql='select * from #t where summary like ''%'+@summary+'%'' order by ttime desc'
exec(@Ssql)
end
else
begin
set @Ssql='select * from #t where summary like ''%'+@summary+'%''and ttime < '''+@strtotime+''' and ttime >'''+@strfromtime+''' order by ttime desc'
exec(@Ssql)
end
else
if @summary=''
if @fromtime=''
begin
set @Ssql='select * from #t where dwdh='''+@dwdh+''' order by ttime desc'
exec(@Ssql)
end
else
begin
set @Ssql='select * from #t where dwdh='''+@dwdh+''' and ttime < '''+@strtotime+''' and ttime >'''+@strfromtime+''' order by ttime desc'
exec(@Ssql)
end
else
if @fromtime=''
begin
set @Ssql='select * from #t where dwdh='''+@dwdh+''' and summary like ''%'+@summary+'%'' order by ttime desc'
exec(@Ssql)
end
else
begin
set @Ssql='select * from #t where dwdh='''+@dwdh+''' and summary like ''%'+@summary+'%'' and ttime < '''+@strtotime+''' and ttime >'''+@strfromtime+''' order by ttime desc'
exec(@Ssql)
end





GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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