Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SetNextRow explanation
#4
Solved: 11 Years, 4 Months ago
Hi Vijyendra, you will need to understand the difference between the two i.e. SetCurrentRow and SetNextRow

SetCurrentRow sets the row specified as the current row in your Data Table, where SetNextRow sets the row after the active row as the new current row in the Data table. If the current row is the last row in the Data Table, this sets the first row in the Data Table as the new current row.
in your case here,
Code:
DataTable("MyCol","Action1")=123456
DataTable.GetSheet("Action1").SetNextRow
DataTable("MyCol","Action1")=1255
when you set a value in your first row. it is the last row in your datatable so applying SetNextRow will go back the first row itself,at the same time when you set the next row as your current active row using SetCurrentRow the current active row becomes 2 and applying SetNextRow activates 3rd row (below code)
Code:
DataTable("MyCol","Action1")=123456
row=DataTable.GetSheet("Action1").getCurrentRow
DataTable.SetCurrentRow(row+1)
DataTable.GetSheet("Action1").SetNextRow

if you put a SetNextRow again it will be back to the first row again as the current active is the last row
Code:
DataTable("MyCol","Action1")=123456
row=DataTable.GetSheet("Action1").getCurrentRow
DataTable.SetCurrentRow(row+1)
DataTable.GetSheet("Action1").SetNextRow
DataTable.GetSheet("Action1").SetNextRow

to better understand this, have a look at the below code
Code:
DataTable.SetCurrentRow(1)
DataTable.GetSheet("Action1").SetNextRow
first statement activates the first row as the active row
applying SetNextRow in the second statement activates row 2 as the active row. you can not use setnext row alone.
try this
Code:
DataTable.GetSheet("Action1").SetNextRow
DataTable("MyCol","Action1")=123456
DataTable.GetSheet("Action1").SetNextRow
first stament will work here and goes to next row as by default the active row is 1.
on the second setnextrow stament it goes back to the first row

use SetNextRow only when the next row contains at least one value and use it when you are retriving values from Data table.
while setting values to datatable SetCurrentrow is sufficient, applying SetNextRow may create confusions.

Hope I am able to make it clear to you Smile

Reply


Messages In This Thread
SetNextRow explanation - by vijayendra.shukla - 02-24-2010, 06:27 PM
RE: SetNextRow explanation - by Saket - 02-25-2010, 11:07 AM
RE: SetNextRow explanation - by vijayendra.shukla - 02-25-2010, 12:12 PM
RE: SetNextRow explanation - by Saket - 02-25-2010, 01:38 PM
RE: SetNextRow explanation - by vijayendra.shukla - 02-25-2010, 04:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Shy SetNextRow is not working in QTP 9.2 Vswarna 1 2,381 09-26-2012, 12:00 PM
Last Post: Ankesh

Forum Jump:


Users browsing this thread: 1 Guest(s)