Changing Report Data At Runtime

Stimulsoft Reports.WEB discussion
Post Reply
kinga
Posts: 9
Joined: Mon Mar 26, 2012 10:22 am
Location: England

Changing Report Data At Runtime

Post by kinga »

I have created a Report in the designer and linked it to a table within my database i.e. Select * From and displayed the fields I require.
At runtime I change the dataset depending on user parameters and create a new dataset e.g. Select * From WHERE Wine_Group = 'ENGLAND'

SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = _exportSQL;
da.SelectCommand = cmd;
DataSet ds = new DataSet();
conn.Open();
da.Fill(ds);
conn.Close();

This new dataset contains my new "truncated" data.

I then render my new report

StiReport rpt = new StiReport();
rpt.Load(Server.MapPath("WinesExport.mrt"));


rpt.RegData(ds);
rpt.Render();

The reports still display the original dataset Select * From ??

Any Ideas?

Many Thanks

Andy
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Changing Report Data At Runtime

Post by Alex K. »

Hello,

Please try to use the following code for change query for datasource:

Code: Select all

((StiSqlSource)rpt.Dictionary.DataSources["DataSourceName"]).SqlCommand = newSqlCommand;
Thank you.
kinga
Posts: 9
Joined: Mon Mar 26, 2012 10:22 am
Location: England

Changing Report Data At Runtime

Post by kinga »

Hi Aleksey

Works perfectly :biggrin:

Thanks for your help

Andy
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Changing Report Data At Runtime

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply