登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

图像处理 视频分析 机器视觉 模式识别

方向比努力更重要

 
 
 

日志

 
 
关于我

河北软件开发项目,电子警察卡口项目,公安天网项目,媒体流处理,数字图像处理。媒体服务器 RTSP、图像处理、车牌识别……DCT变换,H.264压缩

Recordset.recordcount的值为-1  

2011-07-08 14:14:56|  分类: VB与VBA |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
Adodc1.CursorLocation   =   adUseClient '设为本地游标



Navigation
Home
FAQ
Ken's Blog
Resources
Contact Ken
Copyright 2000 -



NOTE: click here to see superior alternatives to .RecordCount.

RecordCount returns -1
The use of the ADO Recordset's .RecordCount property requires either the use of:

  • Static or Keyset server-side cursors or
  • A client-side cursor (which returns a Static cursor)

(Note: some OLEDB Providers will return the correct recordcount with an adOpenDynamic cursor, others will not).

By default Recordsets are opened server-side, and with an adOpenForwardOnly cursor. Attempting to access the .RecordCount property with this type of cursor will return -1.

The easiest way to fix this is to change the cursor type to adOpenStatic. Doing this requires you to explicitly create a recordset object:

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdText

Attempting to implicitly create a recordset, eg like this:

Set objRS = objConn.execute(strSQL)

will not work, as the implicitly created recordset will have a default adOpenForwardOnly cursor.

As mentioned above, the alternative method is to use a client-side cursor. The client referred in this case is the OLEDB Cursor Service.

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorLocation = adUseClient
objRS.Open strSQL, objConn,,adLockReadOnly, adCmdText

In order to be able to use server-side cursors and .Recordcount, the Recordset object must support either Approximate Positioning or Bookmarking. There has been discussion on the ActiveServerPages list to the effect that the MS Oracle OLEDB Provider (or earlier versions of this provider) do not support either Approximate Positioning or Bookmarking, hence require client-side cursors in order for .RecordCount to work.

The use of ADO constants requires you to define them. You can get information on doing this here. For more information on the Recordset's .Open method click here.

  评论这张
 
阅读(1388)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018