Forum Discussion
tristaanogre
14 years agoEsteemed Contributor
The way I'm seeing it, you're not even reading the correct row. Your DDT.CurrentDriver.Next is taking you to the row labeled "dict_id", not the row labeled "activation dict".
So, first of all, I'd alter you code like so:
Note the section in bold. That will make sure you're on the correct row.
The next thing is that the values in your "ACTIVE_DICT" row, within the Excel sheet, are entered as booleans and not strings. So, when it tries to do a string comparison, it's not matching. The reason why some work and some don't has to do with the values in the rows above it. The way the Jet engine works is that, unless otherwise specified, the value in the first row for any given column, the data type of that value determines the data type of ALL values in that column. So, for the first few columns, all values in that column are treated as strings because the first value is a string. But after you get out a few columns, the first value is actually numeric so it tries to read the TRUE or FALSE, not as strings, but as numbers and it can't convert.
As a general rule, you need to make sure, when using DDT drivers, to make all values in the same column have the same data type. Try converting your date in the DICT_ID row to be forced to be strings.
FYI, standard usage of the DDT drivers is to read data out row by row and not column by column. That's why the behavior is dependent upon formatting of values based upon row.
So, first of all, I'd alter you code like so:
var Driver = DDT.ExcelDriver(Project.Path + "test4Dss.xls", "test_suite_001");
while (DDT.CurrentDriver.Value(0) != "ACTIVE_DICT")
{
DDT.CurrentDriver.Next()
}
var activate_id = new Array();
for (var k = 0; k < 78; k++)
{
Log.Message("activation dict " + DDT.CurrentDriver.Value(k + 1));
var kk = DDT.CurrentDriver.Value(k + 1);
if(kk == "TRUE"){
activate_id= true;
}else{
activate_id= false;
}
}
}
Note the section in bold. That will make sure you're on the correct row.
The next thing is that the values in your "ACTIVE_DICT" row, within the Excel sheet, are entered as booleans and not strings. So, when it tries to do a string comparison, it's not matching. The reason why some work and some don't has to do with the values in the rows above it. The way the Jet engine works is that, unless otherwise specified, the value in the first row for any given column, the data type of that value determines the data type of ALL values in that column. So, for the first few columns, all values in that column are treated as strings because the first value is a string. But after you get out a few columns, the first value is actually numeric so it tries to read the TRUE or FALSE, not as strings, but as numbers and it can't convert.
As a general rule, you need to make sure, when using DDT drivers, to make all values in the same column have the same data type. Try converting your date in the DICT_ID row to be forced to be strings.
FYI, standard usage of the DDT drivers is to read data out row by row and not column by column. That's why the behavior is dependent upon formatting of values based upon row.
Related Content
- 8 years ago
- 12 years ago
- 3 years ago
- 3 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago