Change datasource at runtime

Stimulsoft Reports.NET discussion
Post Reply
vorauler
Posts: 71
Joined: Wed Jul 15, 2009 1:20 am

Change datasource at runtime

Post by vorauler »

Hi

I'm just evaluate your product and have a problem to change the datasource of a report at runtime.
I describe my procceding.
1. Create a database wit a table CREATE TABLE Zivilstand (Zivilstand Char( 1 ),Bezeichnung Char( 50 ))
2. Create a view CREATE VIEW viewZivilstandList AS select * from zivilstand;
3. Start the external designer and make a new connection to the database and select the previous view as datasource
4. Drag and drop the fields from the view onto the report and save the report
5. Create a new solution and use this code

Code: Select all

IList list = new List();
list.Add(new viewZivilstandList(){Zivilstand = "l", Bezeichnung = "ledig"});
list.Add(new viewZivilstandList(){Zivilstand = "v", Bezeichnung = "Verheiratet"});

StiReport report = new StiReport();
report.Load(@"d:\Bericht1.mrt");
report.RegData("viewZivilstandList ", list);
report.Show();
But the report display always the data from the database, what' wrong with this approch?

TIA
vorauler
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Change datasource at runtime

Post by Jan »

Hello,

Please use following code:

Code: Select all

report.Databases.Clear();
report.RegData(("viewZivilstandList ", list);
report.Synchronize();
report.Show();
If Show method will be throw exceptions replace it with Design method. You can understand whats wrong with help of report designer and your runtime data.

Thank you.
Post Reply