XML Data and report with parameters

Stimulsoft Reports.NET discussion
luczan
Posts: 32
Joined: Wed Jan 19, 2011 3:50 am
Location: Slovakia

XML Data and report with parameters

Post by luczan »

hi!
Is it possible to add parameter if i make a report with type of connection "Xml Data"?

e.g. i have XSD and XML from your examples (Demo.xsd, Demo.xml) and i need to make a report in which the columns are retrieved by the following query : select * from Employees where EmployeeID > @EmployeeID

thanks
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

XML Data and report with parameters

Post by Ivan »

Hello,

Please use the filter of the databand or filter in datasource "Data from other datasource".

Thank you.
luczan
Posts: 32
Joined: Wed Jan 19, 2011 3:50 am
Location: Slovakia

XML Data and report with parameters

Post by luczan »

i don't know to add a "dinamically" parameter, but only parameter as constant in filter of the databand (@EmployeeID has to be input parameters entered by user). And when i used datasource "Data from other datasource" so i didn't know to use my xsd scheme.

(When i used datasource "Sql Connection" , i have no problem with this task.)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

XML Data and report with parameters

Post by Alex K. »

Hello,

Please see the sample report in attachment.

Thank you.
Attachments
802.SampleReport.mrt
(18.47 KiB) Downloaded 622 times
luczan
Posts: 32
Joined: Wed Jan 19, 2011 3:50 am
Location: Slovakia

XML Data and report with parameters

Post by luczan »

it's done...
thanks for helping me.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

XML Data and report with parameters

Post by Alex K. »

Hello,

Let us know if you need any additional help.

Thank you.
luczan
Posts: 32
Joined: Wed Jan 19, 2011 3:50 am
Location: Slovakia

XML Data and report with parameters

Post by luczan »

Thanks, I have another problem with variables in this report:

i have added a new variable with following parameters
Name: _DateVar
Type: datetime
Default Value: Today (selected from a list of system variables)
Read Only: false
Function: true
Request from User: false


This variable is used in filter of the databand:
Field Is: Expression
Membership.ExpirationDate > _DateVal

Report preview in Designer tool is ok, but i have a problem with report's execution in my app:

....
report.Load(......);
DataSet ds = new DataSet();
ds.ReadXmlSchema("SE.xsd");
ds.ReadXml("SE.xml");
report.Dictionary.DataStore.Clear();
report.Dictionary.Databases.Clear();
report.RegData("SE", ds);
report.Dictionary.Synchronize();

if (report.Dictionary.Variables.Contains("_DateVar"))
{
report.Dictionary.Variables["_DateVar"].ValueObject = new DateTime(2010, 10, 1);
}

report.Render(false);
report.ExportDocument(StiExportFormat.Pdf,"SE.pdf");
........


error is on line report.Render(false):

c:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,39) : error CS1002: ; expectedc:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,41) : error CS1002: ; expectedc:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,41) : error CS1525: Invalid expression term ':'c:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,42) : error CS1002: ; expectedc:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,44) : error CS1002: ; expectedc:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,44) : error CS1525: Invalid expression term ':'c:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,45) : error CS1002: ; expectedc:\Users\luczan\AppData\Local\Temp\epx4zlip.0.cs(149,48) : error CS1002: ; expected

if _DateVar variable isn't changed (skip of report.Dictionary.Variables["_DateVar"].ValueObject = new DateTime(2010, 10, 1);) - report is rendered without error.

if _DateVar variable has following parameters
Name: _DateVar
Type: datetime
Default Value: 01/24/20011 ...
Read Only: false
Function: false
Request from User: false

report is also rendered without error in my app.



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

XML Data and report with parameters

Post by Alex K. »

Hello,

In this case (Function: true) you can use the following code:

Code: Select all

...
if (report.Dictionary.Variables.Contains("xxx"))
{
    report.Dictionary.Variables["xxx"].ValueObject = "new DateTime(2010, 10, 1);";
}
...
Thank you.
luczan
Posts: 32
Joined: Wed Jan 19, 2011 3:50 am
Location: Slovakia

XML Data and report with parameters

Post by luczan »

great, problem solved
thanks
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

XML Data and report with parameters

Post by Andrew »

Have a nice day!
Post Reply