I have added the Telerik Report Viewer to my windows form and set the report source as ConsignmentReport.Report1, ConsignmentReport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. ConsignmentReport is my telerik report designer class. My datasource for the designer is MySql and my sql query needs a parameter. I've set the connection string, data provider, query and parameter in the designer and everything works correctly in the designer preview. My parameter name is #jsno
Then, I tried to add the parameter for the ReportViewer like this
reportViewer1.ReportSource.Parameters[0].Value = "19020312";
and it did not work.
Also tried to add like this
reportViewer1.ReportSource.Parameters.add(new Telerik.Reporting.Parameter("#jsno","19020312"));
Also did not work.
My report viewer remains blank. When tried to remove the parameter from the query and just run the report viewer with simple select statement, the report is generated. So how could I add the parameter to the report source?
The report source parameters enable passing values to the report parameters. So, you need to first add a report parameter to the report definition, in order to be able to pass a value from the report source. On the other hand, you have the data source component which has its own parameters. To bind the data source parameter to the report parameter, do set the following expression as a value of the data source parameter: =Parameters.jsno
Then, at runtime to pass a concrete parameter value to the report, use the second snippet:
reportViewer1.ReportSource.Parameters.add(new Telerik.Reporting.Parameter("#jsno","19020312"));
More info at Using Parameters with the SqlDataSource component (You can use the designer to make the setup)
Related
I have a crystal report and in design time on VS2010 I apply a parameter field via the [Database Expert][Add cmd][create parameter] wizard. But this prompts me for a specific value for my new parameter. I don't see why it should as its going to be dynamic!
In my c# code, my solution only works if the dynamic value at run time matches the design-time prompted value. This seems to defeat the purpose.
In my run-time code I have:
crystalReport.SetParameterValue("TenantID", tenantID);
TenanID is the CR parameter in design time
tenanID is the picked up dynamic value
Can't i make this truly dynamic?
Use:
crystalReport.ParameterFields(1).AddCurrentValue (num)
where "num" is your parameter value
I wrote a custom assembly to take a parameter value from the report and return a field from the dataset collection.
My assembly returns the correct fields!name.value, but it shows me the string representation of it. How can I get it to resolve as the actual fields!name.value to display the actual data in the dataset?
If I enter fields!name.value in manually it works fine showing me the value. If I resolve it with my custom code it display "fields!name.value" to me in the cell.
I am using Crystal Report with C#.
For Desktop.
I want to hyperlink to another report with some parameter.
eg. I show Invoice's Summary (invoice.rpt) like its number (named InvNo), date, items and TotalAmount.
If i click InvNo "0001", then it will passing the InvNo to Item's Summary (item.rpt)
Is it possible?
IF possible, i think it will need some code in crystal report formula, please give me the formula example too.
At first, I thought the answer was 'not possible', but after some experimentation I got farther than I expected.
I created two reports based on the Xtreme.mdb file, named customers.rpt and order.rpt.
The customer.rpt has two columns: Customer Name and Order ID. The order.rpt has three columns: Order ID, Order Date, and Order Amount.
The goal: if I click on the Order ID field in the customers report it opens the order report and generates it for that Order ID.
I added the following to the condition formula associated with the Order ID's Hyperlink:
"file:///C:/Documents and Settings/Administrator/Desktop/order.rpt " + ToText({Orders.Order ID},"#")
When I click on the link, I get the following dialog:
Unfortunately, Crystal Reports' EXE doesn't support command-line arguments, so the action fails:
To get this to work, you would need to create an application that can process the command-line arguments for Crystal Reports. It would have the following characteristics:
packaged as an EXE
'wrap' the Crystal Report Viewer control (you probably don't need any 'design' functionality)
handle database authentication
most importantly, it needs to support command-line arguments. in this regard, you could probably model your argument list on BusinessObjecs's URL Reporting.
HY! I have a form application in visual studio 2010 and I want to create a report with report viewer and to add some parameters. I tried to add parameters from code but it didn`t work. I have this error:
FilterExpression expression for the tablix ‘Tablix1’ refers to the field ‘datastart’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.
Report2.rdlc : error rsParameterReference: The FilterValue expression for the tablix ‘Tablix1’ refers to a non-existing report parameter ‘datastart’.
In my code a do this:
private void SetReportParameters()
{
ReportParameter[] parameters = new ReportParameter[2];
parameters[0] = new ReportParameter("datastart", dateTimePickerStartRaport.Text);
parameters[1] = new ReportParameter("dataStop", dateTimePickerStopRaport.Text);
this.reportViewer1.LocalReport.SetParameters(parameters);
}
and after calling this method a make a refresh on the report viewer
reportViewer1.RefreshReport();
I also look at other forums and I saw that I have to add the parameters to the report, but I didn`t manage out how must I do this. I also tried to add, in the properties windows of the report, some filters with value
=Parameters!datastart.Value
but this also didn`t work.
The error you get is because you try to specify your parameter like a field. In the expression-designer you have a special category called "Parameters". From there you can access your parameters.
The syntax is =Parameters![FieldName].Value. In your case for example =Parameters!datastart.Value.
Additionaly, note that the parameters must be declared in the "Report Data"-window under "Parameters". Its the same window as you use to declare your recordsets, however there is also a special category for parameters. There are also some options for the datatype and if specification of the parameter is mandatory.
So when you create report definition (rdl or rdlc file) you have to add parameters with exactly the same names. So for your case you have to add datastart and dataStop parameters. To do it just click Parameters in Report Data Window and click add new.
Try this:
ReportParameter PrmInvoiceNo = new ReportParameter("PrmInvoiceNo");
PrmInvoiceNo.Values.Add(this.InvNo.ToString());
this.reportViewer1.LocalReport.SetParameters(PrmInvoiceNo);
I have added a parameter to my report with the option "Allow Multiple Values" checked.
This is a status column (IE, Proposed, In Progress, Completed, Canceled), and I want the user to be able to select which (and how many) different OrderStatus to report on.
How I normally set parameters is:
report.SetParameterValue("#dtBegin", dtBegin.DateTime);
What I tried to do for the multiple values was something like this:
//pseudo loop
foreach(int intOrderStatus in intSelectedOrderStatuses)
{
report.Parameter_OrderStatus.CurrentValues.AddValue(intOrderStatus);
}
I have checked it does add the values to the OrderStatus parameter, but when the report runs, the CrystalReports dialog pops up and asks me to enter values for the OrderStatus parameter. So it seems as though the values aren't "commited" to the parameter. I have done a number of searches and can't figure out why it's not working.
Thanks,
Just set the parameter value with an array of ints.
report.SetParameterValue("#OrderStatus", new int[]{1,2,3});
in the select expert you would use the in operator.
{table.order_status_id} in {?#OrderStatus}
What you can do is, make a normal parameter field,i.e without multiple values, only discreet values true, all you need to pass is 1,2,3,4. "," is the delimiter for separation use what ever you think works for you, then in record selection formula simply put
{table.order_status_id} in split({#OrderStatus}, ",")
all you need to pass from you page is the string 1,2,3,4 and it should work
Have you set the parameter to Hidden in the Crystal Reports parameter options?
I haven't tried this, but I think that you should be able to add intOrderStatus to either a ParameterDiscreteValue or ParameterRangeValue and pass that into Parameter_OrderStatus.CurrentValues instead of intOrderStatus.
Well i have same issue. The work around is very simple. Don't add data source after parameters. e.g
report.SetParameterValue("#dtBegin", dtBegin.DateTime);
report.SetParameterValue("#dtBegin2", dtBegin.DateTime1);
//Note datasource is assigned after parameters
report.SetDatasource(dataset);
The crystal report will refresh parameters before applying data source to report.
The below is the not popup discrete dialog box
//Note Datasource is applied before parameters
report.SetDatasource(dataset);
report.SetParameterValue("#dtBegin", dtBegin.DateTime);
report.SetParameterValue("#dtBegin2", dtBegin.DateTime1);
Following is tested in Crystal Reports version 13.0.20:
1) In Parameter Fields section add new parameter as follow:
Name: ParamMultipleOrderStatus
Type: Number
Value Options:
Allow multiple values: true
2) Choose the Select Expert Record ... in Crystal Reports and code may like this (use = operator):
{Orders.OrderStatus} = {?ParamMultipleOrderStatus}
3) Use following code:
foreach (int intOrderStatus in intSelectedOrderStatuses)
{
report.ParameterFields["ParamMultipleOrderStatus"].CurrentValues.AddValue(intOrderStatus);
}