Update datasource via application

Stimulsoft Reports.NET discussion
User avatar
Hessam8008
Posts: 10
Joined: Sat Jun 27, 2015 10:40 am

Update datasource via application

Post by Hessam8008 »

Hi,
I've created a report which is included an SQL data source.
Then, two other data sources created from "Data from other data source" which is derived from the first data source.
I use below code to feed my report via my application :

Code: Select all

With ReportDocumnet
                    .Load(<MyReportPath>)
                    .Compile()
                    .Dictionary.Clear()
                    .RegData(<myDataTable>)
                    .Dictionary.Synchronize()
                    .Render()
With
When I want to see result, NullRefrenceException throw! I think because of .Dictionary.Clear(), clear all data sources and after that I only create one data source ( .RegData(<myDataTable>) ) and my report miss two other data sources. How should I feed my report correctly ?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Update datasource via application

Post by HighAley »

Hello.

Could you describe your issue more detailed?
You write that you use SQL data source with Data from Other Data Source but in code you register a table.
What table do you register?
How do you use SQL Data Source?
What version do you use?

Thank you.
User avatar
Hessam8008
Posts: 10
Joined: Sat Jun 27, 2015 10:40 am

Re: Update datasource via application

Post by Hessam8008 »

Hi,
I only load a data table from SQL into stiReport. On the other hand I need to display different charts, so, I use 'Data from Other Data Source' which is based on previous data table to create summarized structure.
Problem is when I pass the data table to stiReport via my application: No changes in charts!! :?:
I have attached my sample report.
Version : 2014.3.0
Attachments
TimeAndDay.mrt
Sample report
(25.26 KiB) Downloaded 431 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Update datasource via application

Post by HighAley »

Hello.

Please, try to add next methods before registering the table:

Code: Select all

.Dictionary.Databases.Clear();
.Dictionary.DataSources.Clear();
Thank you.
User avatar
Hessam8008
Posts: 10
Joined: Sat Jun 27, 2015 10:40 am

Re: Update datasource via application

Post by Hessam8008 »

Hello,
Unfortunately it doesn't work and throw an error : The name 'GroupByDay' does not exist in the current context.
By the way, if I eliminate parts of my report that use 'GroupByDay', then, those codes work properly!!!

Thank you.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Update datasource via application

Post by Ivan »

Hello,
I only load a data table from SQL into stiReport.
But your report is already contain a SQL datasource "rpt_TimeAndDay".
Please try to do the following: in designer delete the "rpt_TimeAndDay" datasource from dictionary, then use the following code:

Code: Select all

With ReportDocument
                    .Load(<MyReportPath>)
                    .RegData("rpt_TimeAndDay", <myDataTable>)
                    .Dictionary.Synchronize()
                    .Compile()
                    .Render()
With
Thank you.
User avatar
Hessam8008
Posts: 10
Joined: Sat Jun 27, 2015 10:40 am

Re: Update datasource via application

Post by Hessam8008 »

Hello,
Ivan wrote: Please try to do the following: in designer delete the "rpt_TimeAndDay" datasource from dictionary...
It dose NOT work and generate errors!!!
"rpt_TimeAndDay" is the only data table that I pass to stiReport. Other sources in stiReport use that data table.

Thank you.
Attachments
Screenshot (7) copy.jpg
Screenshot (7) copy.jpg (275.32 KiB) Viewed 4637 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Update datasource via application

Post by Alex K. »

Hello,

Please send us a sample project which reproduce the issue for analysis.

Thank you.
User avatar
Hessam8008
Posts: 10
Joined: Sat Jun 27, 2015 10:40 am

Re: Update datasource via application

Post by Hessam8008 »

Hello,

I have attached my sample project.

Thank you.
Attachments
stiReport.zip
Sample report
(1.93 MiB) Downloaded 424 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Update datasource via application

Post by HighAley »

Hello.

You have connection and data source in the report. Why do you register it again.
If the connection is right, report engine will take all necessary data.
It's better to write SQL queries instead of using Data Source from Other Data Source. This scenario will work much faster on large data.

Thank you.
Post Reply