Combine data from two datasources

Stimulsoft Reports.WEB discussion
Post Reply
cbrydon
Posts: 173
Joined: Fri May 30, 2014 4:37 pm

Combine data from two datasources

Post by cbrydon »

Hello,

I have a report with two different SQL Data Connections. Each Data Connection has one datasource. Both datasources
contain the same type of information (Equipment Name and Runtime hours), but from different periods of time. I would
like to be able to combine the two datasources into a third datasource.

Is it possible to create a new DataTable in the report with columns for EquipmentName and RuntimeHours and then in
the report BeginRender event loop through the rows from each datasource and populate the DataTable?

Perhaps using something like the following pseudo code...

rows = this.Dictionary.DataSources["DataSource1].Rows[]
for each row in rows
DataTable.Add(row(this.Dictionary.DataSources["DataSource1"].Columns["EquipmentName"],this.Dictionary.DataSources["DataSource1"].Columns["RuntimeHours"]))
rows.next()

rows = this.Dictionary.DataSources["DataSource2].Rows[]
for each row in rows
DataTable.Add(row(this.Dictionary.DataSources["DataSource2"].Columns["EquipmentName"],this.Dictionary.DataSources["DataSource2"].Columns["RuntimeHours"]))
rows.next()

Thanks,
Carl
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: Combine data from two datasources

Post by Lech Kulikowski »

Hello,

It is not possible. Please try to use the "union" in your sql query.

Thank you.
cbrydon
Posts: 173
Joined: Fri May 30, 2014 4:37 pm

Re: Combine data from two datasources

Post by cbrydon »

Thanks Lech,

I didn't think it was possible, but wanted to double-check. In this case the two datasources are from two different SQL connections so using a UNION isn't possible.
I'll probably end up using a Linked Server. Performance can sometime be slow with linked servers, but I won't be retrieving that much data so am not too concerned.

Carl
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: Combine data from two datasources

Post by Lech Kulikowski »

Hello

Ok.
Please let us know if you need any additional help.

Thank you.
Post Reply