Display Parameter value on SSRS Report - c#

I am very new to SSRS.
I have added one Parameter named Date on SQL Server Report
i have set parameter value from aspx.cs code behind file
i have drown that parameter on ReportHeader and i want display CurrentDate value on that parameter
and i tried =Join(Parameters!Date.Value,", ") but it displays #Error at runtime.
i also tried =Join(Parameters!Date.Label,", ") but it displays Nothing.
Please tell me how to display Parameter value on Report?

Not sure I understand what you are asking. To display the parameter value on the report, create a textbox on the report and then set it's expression to your parametername.value.
Something like this:
=Parameters!Date.Value(0)

Not sure what ur asking ...wheather u need report run date or parameter passing date ....
If u need report date .... follow this
Drag a textbox onto the report ...page header or footer
and ----> =Today()
If u need parameter value(date) what ur passing
Just the parameters!paraame.value ...

If I'm understanding your correctly you want to do:
=Parameters!Date.Value & ", "
& is the string concatentation operator in SSRS, you must have a space on each side of it FYI

Related

unbounded field in crystal report by pass parameter at runtime

I have a report in crystal report.
In that report, I need to set the field to 'Go' if the value is 0, and set the field to 'NoGo' if the value is 1.
I have created an unbound field string and write formula as below:
if {?idline}=1 and tonumber({bevarage;1.torque})=0 then {#UnboundString2}='Go'
else if {?idline}=1 and tonumber({bevarage;1.torque})=1 then {#UnboundString2}='NoGo'
but this is not working and always returns an empty string from unbounded field.
Please help me to fix it.
Assignment operator in Crystal is := rather than =
Why not simply create a formula that depends on the parameter?

Pass a null date to a crystal report parameter using SetParameterValue

I have a situation where I have a crystal report where I pass in a start and end date via rdoc.SetParameterValue this works fine, except that, I do not want it to show a date if I pass nothing for the date variable, I just want it to be blank
To an attempt to do so i have written
if (DateStart != defaultDate)
{
rdoc.SetParameterValue("DStart", DateStart);
}else
{
rdoc.SetParameterValue("DStart", "");
}
Which gives me the error The types of the parameter field and parameter field current values are not compatible of course, this makes sense because I am trying to set a date to a string variable.
However, I am unable to think of a solution, nor do I see any solution in the Parameter's menu.
Appreciate it if I be given some assistance to solve this.
Regards
You may change the parameter type to string and pass the date as string:
DateStart.ToString()
I don't like this solution, but it works. Usually i just require the date.

How to "force" an Crystal Reports optional parameter to not need a value

I have a crystal report that has an optional parameter called Supplier Name.
My Selection Expert logic is set up like this:
**if hasvalue({?Supplier Name}) then
{q_InStockItems_ByUnitSize_vw.primary_supplier_id} = {?Supplier Name}
else
true
So if no value is entered in the optional parameter, all the records are returned.
I am populating the parameter via C# using the following line of code:
InventoryReport.SetParameterValue("Supplier Name", SupplierID);
The problem I am experiencing is that I want to have the ability to not programmatically pass a value to the optional parameter, so all the records are returned.
If I don't specifically provide a value to the optional parameter, Crystal Reports opens the report, and displays the parameter entry window.
I can hit ok and all the records get displayed, but I'm hoping there is some way to skip over the above step.
Try this
if IsNull({?Supplier Name}) then true;
else {q_InStockItems_ByUnitSize_vw.primary_supplier_id} = {?Supplier Name};

Parameters not being passed correctly through code

My report gets data from a stored procedure. Two of the six parameters are dates (toDate and fromDate.) I integrate the report with C# Winforms and I pass the parameters through code the code with:
reportDocument.setParamterValue(0,paramValue);
The report works fine but does not render data despite showing the column header properly. When I refresh the report, it pops up the parameter window again. When I enter the parameters through that window the data shows, including column headers. But it doesn't work when I pass parameters through code.
How can I resolve this?
It looks like this:
CRPT.SetParameterValue("smonth", Servercls.month);
See this link for more info.
I suggest first of all call procedure in c# environment and save result in datatable and then send datatable to crystal report.
I found the error.
First it was not working with setting parameters through indexing. so i set the parameters through name as reds suggested.
second i was missing the parameters binding with report viewer object.
so i added the following line and it worked
crystalReportViewer.ParameterField.addRange(reportDocument.ParameterFields);
Thanks for the answers guys.

SSRS report parameter

I have a problem with rendering report with correct parameter.
We have RDL report that has date parameter with default value which is an expression "=today()".
In project i have the following code in c#
for(int i = 0; i < 15; i++)
{
serverReport.SetParameters(new ReportParameter("dt1",date.ToString()));
File.WriteAllBytes(path, serverReport.Render("PDF"));
}
For first iteration sql stored procedure is called with the default parameter and following iterations are called with passed date(i checked it with sql profiler).
I want to mension that in loop i have many other reports with exact same default date parameter but the problem is with this one. I have compared all parameter properties in 2 repors(one that works and the other that is not working properly), but they are identical. I cant find any difference.
If i delete default value "=today()" then report is working fine.
Maybe sameone had similar problem and recommend me something about this. Thanks in advance.
A few things to check:
SetParameters takes IEnumerable<ReportParameter> not a single ReportParameter object. Call it like this instead:
serverReport.SetParameters(new ReportParameter[] { ReportParameter("dt1", date.ToString()) } );
Make sure that the parameter does not have the available values filled in as well as the default value. If the date passed is not one of the valid values (if applied) it won't work. For example, if the available values are set to =Today then the only report that will run properly is the first one that coincidentally uses that value.
Are you sure that date.ToString() is passing an appropriate and valid date?
Does the server's report parameter match the development environment? Parameter settings aren't automatically updated so that any modifications made on the server aren't overwritten by deploying the report again. Check the server's report parameters and update if necessary, or simply delete and redeploy the report.
Try to completely remove the not working report within the server (and to test,also one of the working) and re-deploy both to the server. you could also check in reporting manager for the parameter settings, because there the difference might be visible.
I had that kind of issues before with report parameters and know that the parameter settings are not overwritten correctly all the time you deploy the report.

Categories

Resources