Add rows from different applications to DataTable
I have a question regarding the DataTable. I have multiple applications which each one consists of number of rows. I need to extract the values of the rows of each application and add it to the dataTable. I am able to add the rows of the first application, but when QTP opens the second application to add the rows value, it overwrites the values from the first application.
I tried to use DataTable.GetRowCount to get last row in the dataTable and then use DataTable.SetNextRow, but it is not working. Here is a scenario:
Application A has 10 Rows and Application B has 30 rows; how to add all of these rows in the DataTable
SetNextRow spec says that If the current row is the last row in the data table, applying this method sets the first row in the data table as the new current row. Is this situation?
Maybe the way I did it is not correct. If you understand my scenario, please provide me with a good way to approach this issue
Perhaps use .SetCurrentRow(x)
You can use .GetRowCount()
Then add +1 and use it in .SetCurrentRow().
I think that SetCurrentRow() allows you to move to it as long as it is not more than one row number above the current row count.
Get row count from application 'A' and do fetch the details, once it's done get row count from application 'B' and add the row count to application 'A' row count as below
Use SetCurrentRow() function for row pointer
rowcount = getrowcount('A')
rowcount = rowcount + getrowcount('B')
I would perhaps use a similar way what bklabel1 has suggested.
GetRowCount and set the current row to the +1 row
It doesn't look like adding rows to the DataTable dynamically is allowed. From the QTP help for DataTable.SetCurrentRow:
So you cannot set it to the last+1 row.
You can set a row only if it contains at least one value.
I would recommend writing the values you need to Excel, using the automation object, or maybe a csv file. If you cannot find good information on how to do that, I can provide some examples.
In previous versions of QTP, I could create a row of data. It could only add a row if it is after the highest row number of data. For example: There is data on rows 1,2,3,4. I could add data to row 5 but not 6.
I have not tried in QTP 11 or UFT.
I put a break point on the x= 1 line.
It allow me to put values into any place on the data sheet.
DataTable("Kevin",dtGlobalSheet) = "Row 1"
DataTable("Kevin",dtGlobalSheet) = "Row 2"
DataTable("Kevin",dtGlobalSheet) = "Row 5"
x = 1
you mean the help file lied!? inconceivable!