Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Item cannot be found in the collection corresponding to the requested name or ordinal in qtp

in a certain scenario, i was trying to use the select query inside QTP (More specifically QTP Using VB script) But the code is not working.

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 knowing which section of the code is getting script result fail.

like image 239
Girish Avatar asked Sep 30 '14 11:09

Girish


1 Answers

"Item cannot be found in the collection corresponding to the requested name" - this error comes when the field is not present in the recordset which you are trying to refer to!

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

  rs.fields("v1")

So, it should be

rs.fields("STATUS")
like image 104
vins Avatar answered Dec 27 '22 02:12

vins