Page 1 of 2

XML Data and report with parameters

Posted: Wed Jan 19, 2011 4:19 am
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

XML Data and report with parameters

Posted: Wed Jan 19, 2011 7:21 am
by Ivan
Hello,

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

Thank you.

XML Data and report with parameters

Posted: Wed Jan 19, 2011 1:15 pm
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.)

XML Data and report with parameters

Posted: Thu Jan 20, 2011 8:48 am
by Alex K.
Hello,

Please see the sample report in attachment.

Thank you.

XML Data and report with parameters

Posted: Fri Jan 21, 2011 2:05 am
by luczan
it's done...
thanks for helping me.

XML Data and report with parameters

Posted: Fri Jan 21, 2011 2:20 am
by Alex K.
Hello,

Let us know if you need any additional help.

Thank you.

XML Data and report with parameters

Posted: Mon Jan 24, 2011 8:53 am
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.




XML Data and report with parameters

Posted: Tue Jan 25, 2011 1:10 am
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.

XML Data and report with parameters

Posted: Tue Jan 25, 2011 2:25 am
by luczan
great, problem solved
thanks

XML Data and report with parameters

Posted: Tue Jan 25, 2011 2:30 am
by Andrew
Have a nice day!