Page 1 of 2

Refresh data in preview

Posted: Wed Sep 19, 2007 7:28 am
by Ralph
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();
}


Refresh data in preview

Posted: Wed Sep 19, 2007 7:31 am
by Fabio Pagano
Try this.

Before RegData:

Code: Select all

stiReport.Dictionary.DataSources.Clear()
After RegData:

Code: Select all

stiReport.Dictionary.Synchronize()

Refresh data in preview

Posted: Wed Sep 19, 2007 9:23 am
by Ralph
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?

Refresh data in preview

Posted: Wed Sep 19, 2007 9:36 am
by Fabio Pagano
Actually, nothing more special.

Thanks.

Refresh data in preview

Posted: Wed Sep 19, 2007 10:26 am
by Ralph
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

Refresh data in preview

Posted: Thu Sep 20, 2007 5:25 am
by Brendan
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:

Code: Select all

Console.WriteLine(bestellDataSet.Tables[boBestellMengen.TableName].Rows.Count);
If the number is increasing by a factor of two then it may be the case that the table has no primary key.

Refresh data in preview

Posted: Thu Sep 20, 2007 10:24 am
by Ralph
Hi Brendan,

I checked this twice:

Code: Select all

bmaDS.Tables["Bestellung"].IsPrimaryKeyField("unique_id")
is allways true.

Nevertheless I added

Code: Select all

bmaDS.Tables["Bestellung"].PrimaryKey = new DataColumn[] { bmaDS.Tables["Bestellung"].Columns["unique_id"] };
to my code to be sure.

But unfortunately it doesn't change anything.
Brendan wrote: If the number is increasing by a factor of two...
Yes, that's the case.
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

Posted: Thu Sep 20, 2007 10:37 am
by Ralph
Hi all, hi again Brendan! :-)

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;
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


Refresh data in preview

Posted: Thu Sep 20, 2007 12:08 pm
by Fabio Pagano
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!
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.

Refresh data in preview

Posted: Fri Sep 21, 2007 5:00 am
by Ralph
Hi Fabio,
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.
yeah, SR.NET is best I could find. Bought my copy today too! :-)

Friendly greetings,

Ralph