行集不支持向后滚动 [英] Rowset does not support scrolling backward

查看:48
本文介绍了行集不支持向后滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码查询 MySQL 数据库:

I am trying to query a MySQL database with the below code:

'declare the variables 
Dim Connection
Dim Recordset
Dim SQL

'declare the SQL statement that will query the database
SQL = "SELECT * FROM CUSIP"

'create an instance of the ADO connection and recordset objects
Set Connection = CreateObject("ADODB.Connection")
Set Recordset = CreateObject("ADODB.Recordset")

'open the connection to the database
Connection.Open "DSN=CCS_DSN;UID=root;PWD=password;Database=CCS"

Recordset.CursorType=adOpenDynamic

'Open the recordset object executing the SQL statement and return records 

Recordset.Open SQL,Connection
Recordset.MoveFirst

If Recordset.Find ("CUSIP_NAME='somevalue'") Then
    MsgBox "Found"
Else
    MsgBox "Not Found"
End If


'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing

每当我执行上述操作时,我都会收到错误消息行集不支持向后滚动",有什么建议吗?

Whenever I execute the above I get an error 'rowset does not support scrolling backward', any suggestions?

推荐答案

adOpenDynamic 未在 VBScript 中声明,因此等于 Empty,被转换为 0 当您分配 CursorType 属性时.
0adOpenForwardOnly,而 forward only 不支持向后移动,这是 Find 方法想要的能力.

adOpenDynamic is not declared in VBScript and therefore equals Empty, which gets converted to 0 when you assign the CursorType property.
0 is adOpenForwardOnly, and forward only does not support moving backwards, an ability the Find method wants.

您应该将 adOpenDynamic 替换为其文字值:

You should replace adOpenDynamic with its literal value:

Recordset.CursorType = 2 'adOpenDynamic

要完全避免此类错误,请将 Option Explicit 作为脚本的第一行.

To avoid this class of errors altogether, place Option Explicit as the first line of your script.

这篇关于行集不支持向后滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆