Refresh data in preview
Refresh data in preview
Hello,
I have a button on a form with a stiReport and a stiPreviewControl on it. What I try to accomplish is, that a click on this button refreshes all data, which could be changed meantime. Unfortunately I don't get it to work. What do I do wrong?
Many thanks in advance and friendly greetings,
Ralph
------ example ------- (bo... = BusinessObject)
private void buttonAktualisieren_Click(object sender, EventArgs e)
{
stiReport.DataStore.Clear();
boBestellMengen.FillByBestellmenge();
boBestellArtikel.FillByParent();
bestellDataSet.Tables[boBestellMengen.TableName].Load(boBestellMengen.CurrentView.Table.CreateDataReader(), LoadOption.OverwriteChanges);
bestellDataSet.Tables[boBestellArtikel.TableName].Load(boBestellArtikel.CurrentView.Table.CreateDataReader(), LoadOption.OverwriteChanges);
stiReport.RegData(this.businessBindingSourceAbsender.BusinessObject.CurrentDataTable.ToString(), this.businessBindingSourceAbsender.BusinessObject.CurrentDataTable);
stiReport.RegData(bestellDataSet);
//stiReport.Load("Bestellung.mrt");
stiReport.Render();
}
I have a button on a form with a stiReport and a stiPreviewControl on it. What I try to accomplish is, that a click on this button refreshes all data, which could be changed meantime. Unfortunately I don't get it to work. What do I do wrong?
Many thanks in advance and friendly greetings,
Ralph
------ example ------- (bo... = BusinessObject)
private void buttonAktualisieren_Click(object sender, EventArgs e)
{
stiReport.DataStore.Clear();
boBestellMengen.FillByBestellmenge();
boBestellArtikel.FillByParent();
bestellDataSet.Tables[boBestellMengen.TableName].Load(boBestellMengen.CurrentView.Table.CreateDataReader(), LoadOption.OverwriteChanges);
bestellDataSet.Tables[boBestellArtikel.TableName].Load(boBestellArtikel.CurrentView.Table.CreateDataReader(), LoadOption.OverwriteChanges);
stiReport.RegData(this.businessBindingSourceAbsender.BusinessObject.CurrentDataTable.ToString(), this.businessBindingSourceAbsender.BusinessObject.CurrentDataTable);
stiReport.RegData(bestellDataSet);
//stiReport.Load("Bestellung.mrt");
stiReport.Render();
}
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
Refresh data in preview
Try this.
Before RegData:
After RegData:
Before RegData:
Code: Select all
stiReport.Dictionary.DataSources.Clear()
Code: Select all
stiReport.Dictionary.Synchronize()
Refresh data in preview
Hi Fabio,
oh, that was quick!
Thank you very much. I never thought of "Dictionary", but unfortunately it makes no difference. I get multiple data entries like before.
Any other hint?
oh, that was quick!

Thank you very much. I never thought of "Dictionary", but unfortunately it makes no difference. I get multiple data entries like before.
Any other hint?
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
Refresh data in preview
Actually, nothing more special.
Thanks.
Thanks.
Refresh data in preview
Hi Fabio,
you are really quick in answering! Nice kind of you!
OK:
I fill my BOs with the new or changed data.
Then I load the new filled tables from the BOs into the dataset of the report.
After that I "clear" the Dictionary.DataSources and "regdata" the dataset.
Then I "syncronize" the Dictionary.
At last I "render" the report.
But what I get is not a Report with the new / changed data, instead I get a report with the same data, but multiple for every click on my button.
Maybe someone else can jumpin' in?
There must be a way. If I close the preview and open the form again, all is working as expected. But I don't want to restart the form anytime there are new data.
Oh, I forgot to mention: StimulReport.Net is great! I'm on the evaluating process right now, but I like it!
TIA and friendly greetings, Ralph
you are really quick in answering! Nice kind of you!

OK:
I fill my BOs with the new or changed data.
Then I load the new filled tables from the BOs into the dataset of the report.
After that I "clear" the Dictionary.DataSources and "regdata" the dataset.
Then I "syncronize" the Dictionary.
At last I "render" the report.
But what I get is not a Report with the new / changed data, instead I get a report with the same data, but multiple for every click on my button.
Maybe someone else can jumpin' in?
There must be a way. If I close the preview and open the form again, all is working as expected. But I don't want to restart the form anytime there are new data.
Oh, I forgot to mention: StimulReport.Net is great! I'm on the evaluating process right now, but I like it!
TIA and friendly greetings, Ralph
Refresh data in preview
Hi Ralph,
The Problem may exist When you are reloading your DataReader back into your Tables with the LoadOption.
If your Tables in the Dataset don't have a Primary Key defined for them the LoadOption.OverwriteChanges will insert all the new data in on top of the existing data without overwriting. Your Tables will need to have a Primary key defined on them so it can tell what is existing data and what is new.
To check if this is happening try adding this line after the first table.Load() method:
If the number is increasing by a factor of two then it may be the case that the table has no primary key.
The Problem may exist When you are reloading your DataReader back into your Tables with the LoadOption.
If your Tables in the Dataset don't have a Primary Key defined for them the LoadOption.OverwriteChanges will insert all the new data in on top of the existing data without overwriting. Your Tables will need to have a Primary key defined on them so it can tell what is existing data and what is new.
To check if this is happening try adding this line after the first table.Load() method:
Code: Select all
Console.WriteLine(bestellDataSet.Tables[boBestellMengen.TableName].Rows.Count);
Refresh data in preview
Hi Brendan,
I checked this twice: is allways true.
Nevertheless I added to my code to be sure.
But unfortunately it doesn't change anything.
It has, but the problem persists.
Is there a way to "kill" all data in a DataSet.Table? Any other hints?
TIA and friendly greetings,
Ralph
I checked this twice:
Code: Select all
bmaDS.Tables["Bestellung"].IsPrimaryKeyField("unique_id")
Nevertheless I added
Code: Select all
bmaDS.Tables["Bestellung"].PrimaryKey = new DataColumn[] { bmaDS.Tables["Bestellung"].Columns["unique_id"] };
But unfortunately it doesn't change anything.
Yes, that's the case.Brendan wrote: If the number is increasing by a factor of two...
Brendan wrote: ...then it may be the case that the table has no primary key.
It has, but the problem persists.
Is there a way to "kill" all data in a DataSet.Table? Any other hints?
TIA and friendly greetings,
Ralph
Refresh data in preview
Hi all, hi again Brendan! 
Found it out: together did the trick. 
Only one of each didn't resolve my problem, but both together did.
Thanks for all your help!
The last few weeks I tried a lot of report designers, e.g. List&Label, Sharp-Shooter, DXReports and a few others, but nothing is so easy and intuitive for me to work as with SR.NET!
Friendly greetings,
Ralph

Found it out:
Code: Select all
bmaDS.Tables["Bestellung"].PrimaryKey = new DataColumn[] { bmaDS.Tables["Bestellung"].Columns["unique_id"] };
bmaDS.Tables["Bestellung"].Columns["unique_id"].Unique = true;

Only one of each didn't resolve my problem, but both together did.
Thanks for all your help!
The last few weeks I tried a lot of report designers, e.g. List&Label, Sharp-Shooter, DXReports and a few others, but nothing is so easy and intuitive for me to work as with SR.NET!
Friendly greetings,
Ralph
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
Refresh data in preview
I've the same opinion. You have tried for few weeks, i've tried for two years many report tools... I believe that Stimulreport is N. 1 and i have just bought it today.Ralph wrote:The last few weeks I tried a lot of report designers, e.g. List&Label, Sharp-Shooter, DXReports and a few others, but nothing is so easy and intuitive for me to work as with SR.NET!
Refresh data in preview
Hi Fabio,

Friendly greetings,
Ralph
yeah, SR.NET is best I could find. Bought my copy today too!Fabio wrote:I've the same opinion. You have tried for few weeks, i've tried for two years many report tools... I believe that Stimulreport is N. 1 and i have just bought it today.

Friendly greetings,
Ralph