The item cannot be found in the collection matching the requested name or order in qtp

in a specific scenario, I tried to use the select query inside QTP (more specifically QTP using a VB script) But the code does not work.

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

Please help me find out what part of the code gets the result of the script.

+4
source share
1 answer

"The item cannot be found in the collection matching the requested name" - this error occurs when the field is absent in the recordset that you are trying to access!

rs will not have "v1" and it has only "STATUS".

  rs.fields("v1")

So it should be

rs.fields("STATUS")
+12
source

All Articles