Micro Focus QTP (UFT) Forums
How to pass all rows from data sheet in a function argument - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to pass all rows from data sheet in a function argument (/Thread-How-to-pass-all-rows-from-data-sheet-in-a-function-argument)



How to pass all rows from data sheet in a function argument - richa07 - 10-15-2012

Hi Friends

I want to write a code which take all the values from the data table row by row as an argument of the function.

If I am using only one row data it is working fine :
BELOW IS THE CODE
Code:
SelectSourceAttribute  is a function
sSourcename=  DataTable("SourceName",  dtGlobalSheet)
sAttrbuteSearch= DataTable("AttributeName", dtGlobalSheet)
msgbox sSourcename
msgbox sAttrbuteSearch
SelectSourceAttribute sSourcename,sAttrbuteSearch

But when same code is used under a for loop its not working, please anybody tell me whats the problem

Code:
For i =1 to RowCount
    sSourcename=  DataTable("SourceName",  dtGlobalSheet)
    sAttrbuteSearch= DataTable("AttributeName", dtGlobalSheet)
    msgbox sSourcename
    msgbox sAttrbuteSearch
    SelectSourceAttribute sSourcename,sAttrbuteSearch
Next

Note: run one iteration is checked when loop is added


RE: How to pass all rows from data sheet in a function argument - srinath_QTP - 10-15-2012

try the below code.....................

Code:
For i =1 to RowCount
sSourcename= DataTable("SourceName", dtGlobalSheet)
sAttrbuteSearch= DataTable("AttributeName", dtGlobalSheet)
msgbox sSourcename
msgbox sAttrbuteSearch
DataTable.SetNextRow
Next

Srinath