在某种情况下,我试图在QTP中使用select查询(更具体地说,QTP使用VB脚本) 但是代码没有用。
Option Explicit
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.open "Driver={Microsoft ODBC for Oracle};Server=myServer; Uid=USERNAME;Pwd=PASSWORD;"
rs.open "SELECT B.STATUS FROM STUDENT B WHERE B.BATCHCODE='FIRST' ",con
Do while not rs.eof
DataTable.GlobalSheet.AddParameter.RawValue = rs.fields("v1")
rs.movenext
Loop
Release objects
Set rs= nothing
Set con= nothing
请帮助我知道代码的哪一部分导致脚本失败。
答案 0 :(得分:14)
"在与所请求的名称相对应的集合中找不到项目" - 当您尝试引用的记录集中不存在该字段时会出现此错误!
rs不会有" v1"它只有"状态"。
rs.fields("v1")
所以,它应该是
rs.fields("STATUS")