我正在尝试使用以下代码查询 MySQL 数据库:
'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
每当我执行上述操作时,我都会收到错误“行集不支持向后滚动”,有什么建议吗?
adOpenDynamic
未在 VBScript 中声明,因此等于Empty
,它被转换为0
当你分配CursorType
财产。
0
is adOpenForwardOnly
,并且只向前移动,不支持向后移动,这是一种能力Find
方法要。
你应该更换adOpenDynamic
及其字面值:
Recordset.CursorType = 2 'adOpenDynamic
为了完全避免此类错误,请将Option Explicit
作为脚本的第一行。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)