Report Already Compiled

Stimulsoft Reports.NET discussion
Post Reply
midsomer
Posts: 5
Joined: Tue Jan 18, 2011 3:56 am
Location: UK

Report Already Compiled

Post by midsomer »

Hi,

First off I would like to say that Stimulsoft Reports is a great tool, and meets all my needs for creating complex documents and reports :feelgood:

Unfortunately, I've come up against a problem:

On my report screen I have added 3 buttons - Generate, Save, and Open.

The Generate button fills various datasets in my report, compiles the report with Compile(), assigns values to report variables, followed by Render() then Show().

The Save button saves the generated report using Report.SaveDocument(FileName)

The Open button loads a previously saved report using Report.LoadDocument(FileName)

My problem is that if I click the Open button to open a previously saved report, then click the Generate button to re-create the original report I get the
"Report Already Compiled" error message on the Compile() statement in my generate function.

Hope you can help.

Stephan1
Posts: 122
Joined: Fri Aug 31, 2007 7:22 am
Location: Germany

Report Already Compiled

Post by Stephan1 »

Hi midsomer,

why not just checking the property like

if stireport.iscompiled = false
compile
...
endif

cheers stephan

Btw. Midsomer your name reminds me of Barnaby midsomer.^^

midsomer
Posts: 5
Joined: Tue Jan 18, 2011 3:56 am
Location: UK

Report Already Compiled

Post by midsomer »

Hi Stephan,

Thanks for the reply.

if stireport.iscompiled = false does stop the error, but then I have a new problem that when the report appears in the viewer the data is missing I only see the elements that are hardcoded in the report design e.g. logo, horizontal and vertical lines etc...

It seems to me that the loaded report from the Open button somehow needs flushing before I generate a new report, but I have found no way to flush a compiled report.

I live in Midsomer Norton, which has no link to Midsomer Murders / Barnaby. I wish I had a pound for every time I'm asked "Is that where all the murders occur" :biggrin:
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Report Already Compiled

Post by Alex K. »

Hello,

You can use the following code:

Code: Select all

private StiReport report = new StiReport();
private void btnOpen_Click(object sender, EventArgs e)
{
    report.LoadDocument("..\\..\\Report.mdc");
    report.Show();
}

private void btnGenerate_Click(object sender, EventArgs e)
{
    StiReport newReport = new StiReport();
    newReport.Load("..\\..\\Report.mrt");
    newReport.Compile();
    newReport.Render();
    newReport.Show();
    report = newReport;
}

private void btnSave_Click(object sender, EventArgs e)
{
    report.SaveDocument("..\\..\\Report.mdc");
}
Thank you.
midsomer
Posts: 5
Joined: Tue Jan 18, 2011 3:56 am
Location: UK

Report Already Compiled

Post by midsomer »

Hi Aleksey,

Excellent, your code does exactly what I want. :feelgood:

I have since also discovered that I can use Report.NeedsCompiling = True to achieve the same effect.

Many thanks,

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

Report Already Compiled

Post by Alex K. »

Hello,

Let us know if you need any additional help.

Thank you.
Post Reply