Page 1 of 1
Convert StiRow to DataRow Error
Posted: Wed Oct 29, 2025 9:58 am
by admin@secsol.co.uk
In my report I have a DataTable (Created from ODBC SQL Connection) and some code that interates through the rows :
Code: Select all
foreach(DataRow Row in StockHistory.Rows
This works on one set of data that I have but on another set of data (identical format) it throws an error saying :
Unable to cast object of type 'Stimulsoft.Report.Dictionary.StiRow' to type 'System.Data.DataRow'
Why would this happen on one set of data and not another?
How do I get around this?
Re: Convert StiRow to DataRow Error
Posted: Wed Oct 29, 2025 10:34 am
by admin@secsol.co.uk
I think I have found the problem, one set of data only returns one row and that works.
Should my code actually read :
foreach(Stimulsoft.Report.Dictionary.StiRow Row in StockHistory.Rows)
{
}
Re: Convert StiRow to DataRow Error
Posted: Wed Oct 29, 2025 11:33 am
by Lech Kulikowski
Hello,
Yes, in this case, you should use Stimulsoft.Report.Dictionary.StiRow.
Thank you.
Re: Convert StiRow to DataRow Error
Posted: Wed Oct 29, 2025 11:55 am
by admin@secsol.co.uk
I have a custom function as below :
int Count = 0;
foreach(Stimulsoft.Report.Dictionary.StiRow Row in StockHistory.Rows)
{
Count++;
Int16 TransferType = (Int16)Row["TransferType"];
Int32 AdjustQty = (Int32)Row["Quantity"];
switch(TransferType)
{
case 1: // Book In
case 2: // Book in Pop
Qty -= AdjustQty;
break;
case 5: // BookOut:
case 6: // BookOutFromAllocated:
case 7: // BookOutFromPopAllocated:
Qty += AdjustQty;
break;
default: break;
}
}
There are 350 record in the StockHistory table and the first time that this function is called Count reaches 350 but every following call the Count value is 0
Re: Convert StiRow to DataRow Error
Posted: Thu Oct 30, 2025 11:28 pm
by Lech Kulikowski
Hello,
Please send your report with test data that reproduces the issue for analysis.
Thank you.
Re: Convert StiRow to DataRow Error
Posted: Fri Oct 31, 2025 9:04 am
by admin@secsol.co.uk
It is very difficult to send you the data.
I have modified the report so on Init. I copy the StockHistory table to a List<> array and then iterate through that array instead - this works fine.
Re: Convert StiRow to DataRow Error
Posted: Fri Oct 31, 2025 11:32 am
by Lech Kulikowski
Hello,
Thank you for the information.