Convert StiRow to DataRow Error

Stimulsoft Reports.NET discussion
Post Reply
admin@secsol.co.uk
Posts: 53
Joined: Wed Jun 01, 2022 8:26 am

Convert StiRow to DataRow Error

Post 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?
Attachments
PrtScr capture.jpg
PrtScr capture.jpg (13.96 KiB) Viewed 506 times
admin@secsol.co.uk
Posts: 53
Joined: Wed Jun 01, 2022 8:26 am

Re: Convert StiRow to DataRow Error

Post 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)
{
}
Lech Kulikowski
Posts: 7466
Joined: Tue Mar 20, 2018 5:34 am

Re: Convert StiRow to DataRow Error

Post by Lech Kulikowski »

Hello,

Yes, in this case, you should use Stimulsoft.Report.Dictionary.StiRow.

Thank you.
admin@secsol.co.uk
Posts: 53
Joined: Wed Jun 01, 2022 8:26 am

Re: Convert StiRow to DataRow Error

Post 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
Lech Kulikowski
Posts: 7466
Joined: Tue Mar 20, 2018 5:34 am

Re: Convert StiRow to DataRow Error

Post by Lech Kulikowski »

Hello,

Please send your report with test data that reproduces the issue for analysis.

Thank you.
admin@secsol.co.uk
Posts: 53
Joined: Wed Jun 01, 2022 8:26 am

Re: Convert StiRow to DataRow Error

Post 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.
Lech Kulikowski
Posts: 7466
Joined: Tue Mar 20, 2018 5:34 am

Re: Convert StiRow to DataRow Error

Post by Lech Kulikowski »

Hello,

Thank you for the information.
Post Reply