Page 1 of 2
Change the sql command before preview
Posted: Wed May 09, 2012 4:23 pm
by marco.correa
Hello,
We need to change a SQL command on a DataSource before "report preview" of the StiDesignerControl.
Where can we put this code to change the SQL of the DataSource?
We added this code below on PreviewingReportInDesigner event but the sql changed not affected the report being viewed.
Code: Select all
StiSqlSource sqlSource = (report.Dictionary.DataSources[0] as StiSqlSource);
sqlSource.SqlCommand = "SELECT * FROM TABLE WHERE {MYVARIABLE};
Thank you.
Change the sql command before preview
Posted: Thu May 10, 2012 3:22 am
by HighAley
Hello.
[quote="marco".correa]We need to change a SQL command on a DataSource before "report preview" of the StiDesignerControl.
Where can we put this code to change the SQL of the DataSource?
We added this code below on PreviewingReportInDesigner event but the sql changed not affected the report being viewed.
Code: Select all
StiSqlSource sqlSource = (report.Dictionary.DataSources[0] as StiSqlSource);
sqlSource.SqlCommand = "SELECT * FROM TABLE WHERE {MYVARIABLE};
[/quote]
It's impossible to do it in the PreviewingReportInDesigner event because the event is called after compiling report.
Please, describe why are you trying to change Sql Command and we'll try to find a way out.
Thank you.
Change the sql command before preview
Posted: Thu May 10, 2012 11:00 am
by marco.correa
Hello,
After your answer I put the code on "ReportCompiling" event and it worked. Is it right to maintain the code there?
How I proceed to cancel a preview using an event ?
Thank you.
Change the sql command before preview
Posted: Fri May 11, 2012 10:25 am
by HighAley
Hello.
[quote="marco".correa]After your answer I put the code on "ReportCompiling" event and it worked. Is it right to maintain the code there?
How I proceed to cancel a preview using an event ?[/quote]
We need more time to prepare an answer for you.
Thank you.
Change the sql command before preview
Posted: Mon May 14, 2012 4:12 am
by HighAley
Hello.
[quote="marco".correa]How I proceed to cancel a preview using an event ?[/quote]
Please, describe your problem more detailed.
Thank you.
Change the sql command before preview
Posted: Mon May 14, 2012 7:25 am
by marco.correa
Hello,
We need to do some verifications before report be displayed.
If some verification fail, we need to cancel the preview of report and show a message to user.
Thank you.
Change the sql command before preview
Posted: Mon May 14, 2012 5:03 pm
by Brainstorm
Normally we run the designer after a "print button" click event, inside that event we do the necessary checks (read: queries) before doing the actual select that will load the report datasets.
Change the sql command before preview
Posted: Wed May 16, 2012 3:59 am
by HighAley
Hello.
[quote="marco".correa]We need to do some verifications before report be displayed.
If some verification fail, we need to cancel the preview of report and show a message to user.[/quote]
What behaviour are you waiting from Designer? If there any problem the report will not be rendered.
Thank you.
Change the sql command before preview
Posted: Wed May 16, 2012 8:32 am
by marco.correa
Hello,
We should like that when "report preview" is canceled the user see a message that is not a error.
Actually we are throwing a exception to cancel a report preview.
Code: Select all
StiOptions.Engine.GlobalEvents.PreviewingReportInDesigner += (s, args) =>
{
// disregard the verification below, this is only a sample to illustrate
// the event that we are using and the exception raised.
if (1 == 1)
throw new Exception("Visualização do relatório cancelada.");
};
Thank you.
Change the sql command before preview
Posted: Thu May 17, 2012 10:03 am
by HighAley
Hello.
[quote="marco".correa]We should like that when "report preview" is canceled the user see a message that is not a error.
Actually we are throwing a exception to cancel a report preview.
Code: Select all
StiOptions.Engine.GlobalEvents.PreviewingReportInDesigner += (s, args) =>
{
// disregard the verification below, this is only a sample to illustrate
// the event that we are using and the exception raised.
if (1 == 1)
throw new Exception("Visualização do relatório cancelada.");
};
[/quote]
You still didn't write what behaviour of the Designer are you waiting for. Do you want the Designer does back to the Design tab?
If there are any error no message will be shown and users will see a blank report. You could show message using MessageBox.Show() method.
Thank you.