Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to append values to the existing datatable in qtp during runtime
#1
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,

I have a problem,
I create a datasheet during runtime and add a web table value which contain header and data during runtime,

now i want to add the next set of values/data(header not needed) to the same datatable retaining the previous header/column names and data along with the new data..

Code am using

Code:
With Browser(---).page(---)
            clcnt=.WebTable("class:=dataGrid").ColumnCount(1)                        
    datatable.AddSheet("TempStatusHold")
    For i=1 to clcnt                    
    columnHeader=.WebTable("class:=dataGrid").GetCellData(1,i)                        
    columnVal=.WebTable("class:=dataGrid").GetCellData(3,i)                        
    datatable.GetSheet("TempStatusHold").AddParameter columnHeader,columnVal                        
    Next
    
      datatable.GetSheet("TempStatusHold").SetNextRow
     (or) datatable.GetSheet("TempStatusHold").SetCurrentRow(3)

     For i=1 to clcnt                                    
     columnVal=.WebTable("class:=dataGrid").GetCellData(3,i)                        
     datatable.GetSheet("TempStatusHold").AddParameter " ",columnVal                        
       Next

End With
====================================================
With the above code,,, the new set of data is replacing the the old value

Please suggest ......
Reply
#2
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,
Please refer to the sample code to add data to a sheet and modify your code accordingly.
Clue: Please see the usage of AddParameter and GetParameter methods
Code:
DataTable.AddSheet("TempStatusHold")
DataTable.GetSheet("TempStatusHold").AddParameter "A","A"
DataTable.GetSheet("TempStatusHold").AddParameter"B","B"
DataTable.GetSheet("TempStatusHold").AddParameter "C","C"
DataTable.GetSheet("TempStatusHold").AddParameter"D","D"
For i=0 to 16
    DataTable.SetCurrentRow(i)
    DataTable.GetSheet("TempStatusHold").GetParameter("A").Value=i
    DataTable.GetSheet("TempStatusHold").GetParameter("B").Value=i
    DataTable.GetSheet("TempStatusHold").GetParameter("C").Value=i
    DataTable.GetSheet("TempStatusHold").GetParameter("D").Value=i
Next

Regards,
Ravi
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Add new recovery scenario to existing tests Autobot 3 3,629 03-08-2017, 08:45 AM
Last Post: workrohit08
  How to change the column name of datatable runtime in UFT sagar.raythatha 0 2,417 01-16-2017, 05:54 PM
Last Post: sagar.raythatha
  How to clear the contents of datatable(Local or Global sheet) during runtime? srinibarati 3 12,998 11-27-2016, 10:10 PM
Last Post: EbbyNader
  QTP crash during runtime. vidhu 3 3,606 07-11-2013, 03:42 PM
Last Post: vinod123
  Creating or Renaming Column of DataTable at RunTime. Girish_Pai 6 25,534 11-15-2011, 11:08 AM
Last Post: ravi.gajul

Forum Jump:


Users browsing this thread: 1 Guest(s)