Combine XML and SQL Datasource in one Databand

Stimulsoft Reports.NET discussion
Post Reply
Rayden
Posts: 4
Joined: Thu Dec 06, 2012 9:36 am

Combine XML and SQL Datasource in one Databand

Post by Rayden »

We have a report which is basically built from a XML File. According to a specific field A in a data record of this xml dataset i should load additional data from a table via SQL and display it in the same DataBand. I tried creating a DataSource to the SQL database and added SQL statement loading all entries matching field A.

But when i preview the report i get only the database data for the first record in the XML File which is then shown in every subsequent record. For every record the the sql query should be processed again with the current key i'm looping in the XML dataset.

Following a example of how it should look like in one record of the Databand:

DS_A = XML Datasource
DS_SQL = SQL Datasource
KEY_A = XML Key Field

DS_A.KEY, DS_A.Field1, DS_A.Field2, DS_A.Field3 .... DS_SQL.Field1, DS_SQL.Field2

where as DS_A.KEY should be used to get the appropriate DS_SQL data record.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Combine XML and SQL Datasource in one Databand

Post by HighAley »

Hello.

You should create a relation between XML Datasource and SQL Datasource.
Set the Cache all Data property of the report to true to make it possible.

Thank you.
Rayden
Posts: 4
Joined: Thu Dec 06, 2012 9:36 am

Re: Combine XML and SQL Datasource in one Databand

Post by Rayden »

Thank you for your fast answer, after some additional testing i found out i had the tables switched in the relation between the 2 datasources, it is working now.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Combine XML and SQL Datasource in one Databand

Post by HighAley »

Hello.
Rayden wrote:Thank you for your fast answer, after some additional testing i found out i had the tables switched in the relation between the 2 datasources, it is working now.
We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Rayden
Posts: 4
Joined: Thu Dec 06, 2012 9:36 am

Re: Combine XML and SQL Datasource in one Databand

Post by Rayden »

I might have another issue but i fear i can't do anything as i can't touch the compiled code calling the report generator:

Code: Select all

      StiReport stiReport = new StiReport();
      stiReport.Load(str2);
      stiReport.RegData((DataTable) auftragDataTable);
      stiReport.Render(false);
I have access to the mrt file but i cant modify the compiled code above calling the report. So when i added the MSSQL datasource in the mrt file, it works like a charm in the report designer but when i execute this mrt inside the webapplication, i get the following error:

Code: Select all

InvalidOperationException: The ConnectionString property has not been initialized
Due to this thread http://forum.stimulsoft.com/viewtopic.php?&t=1914 i think the reason is the way the Report Engine is called. The RegData Command above only registers the XML Data, i mentioned above. If there is any way to load additional data into the report from a MSSQL database without touching the code above that would be great.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Combine XML and SQL Datasource in one Databand

Post by HighAley »

Hello.

Please, try to call the stiReport.Dictionary.DataSources.Clear() method before RegData() method.

Thank you.
Rayden
Posts: 4
Joined: Thu Dec 06, 2012 9:36 am

Re: Combine XML and SQL Datasource in one Databand

Post by Rayden »

Thanks again i was able to code the needed commands into the the mrt file, everything is working now as intended.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Combine XML and SQL Datasource in one Databand

Post by HighAley »

Hello.

Let us know if you will need any additional help.

Thank you.
Post Reply