Forum Discussion
tristaanogre
14 years agoEsteemed Contributor
There are a couple of ways of doing this.
First, if your excel file has a column of unique ID's, you could modify your DDT driver to query for the specific ID's. Something like
Now, the SQL statement I have here might be incorrect... I personally work with CSV files which simplifies the queries a bit.
The second way is to increment through the loop. This takes a bit of a performance hit but it is a legitimate way and actually will translate if you're doing this in a keyword test.
Note, the code has not been tested but that's how I would probably handle it.
First, if your excel file has a column of unique ID's, you could modify your DDT driver to query for the specific ID's. Something like
var MyDDTDriver = DDT.ExcelDriver("C:\\Temp\\MyExcel.XLS", "MyDataSheet", true)
MyDDTDriver.ADOCommandObject.CommandText = "SELECT * from MyExcel.XLS where ID BETWEEN 5 AND 9"
Now, the SQL statement I have here might be incorrect... I personally work with CSV files which simplifies the queries a bit.
The second way is to increment through the loop. This takes a bit of a performance hit but it is a legitimate way and actually will translate if you're doing this in a keyword test.
var MyDDTDriver = DDT.ExcelDriver("C:\\Temp\\MyExcel.XLS", "MyDataSheet", true)
var CurrentRecord=1
var StartRecord = 5;
var EndRecord = 9
for(CurrentRecord=1;CurrentRecord<=StartRecord;CurrentRecord++)
{
MyDDTDriver.Next()
}
while ((!MyDDTDriver.EOF()) && (CurrentRecord <= EndRecord))
{
DoWhatINeedToDo()
CurrentRecord = CurrentRecord++
MyDDTDriver.Next()
}Note, the code has not been tested but that's how I would probably handle it.