gpt4 book ai didi

sql - 行集不支持向后滚动

转载 作者:行者123 更新时间:2023-12-04 18:46:03 25 4
gpt4 key购买 nike

我正在尝试使用以下代码查询 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 时属性(property)。0adOpenForwardOnly ,并且只向前不支持向后移动,一种能力Find方法要。

您应该更换 adOpenDynamic其字面值:

Recordset.CursorType = 2 'adOpenDynamic

为了完全避免此类错误,放置 Option Explicit作为脚本的第一行。

关于sql - 行集不支持向后滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14122308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com