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.
Related
I have a report that deals with presenting a table with data, I use the MvcReportViewerFluent to view the report on the page.
#(Html.MvcReportViewerFluent(Model.ReportPath)
.ReportParameters(Model.ReportParameter)
.Attributes(new { Height = 900, Width = "100%", style = "border: none" })
.ControlSettings(new ControlSettings() {ShowExportControls=true, AsyncRendering=true, ShowReportBody=true })
)
In the report there is a link that is built with the concatenation of various parameters including the baseUrl parameter of the hidden type, for a couple of days this parameter seems as if it were not populated but took its default value.
To populate this parameter I use the ReportParameters property to which I pass a dictionary with the parameter.
model.ReportParameter = new Dictionary<string, object>();
model.ReportParameter.Add("BaseUrl", ConfigurationManager.AppSettings["UrlBase"].ToString());
Note that in addition to this parameter, other parameters that work perfectly are presented on the screen.
I also tried to make this parameter visible and I saw that it is not even populated, the strange fact is that in the test environment it gave the same problem which then solved itself without making any changes.
Not sure exactly what you meant by "the baseUrl parameter of the hidden type". In order to pass hidden parameters to ssrs you just append it to a query string like so:
[BaseurlofSSRS]?[myhiddenparamname]=[value]
This should work.
This was due to a cache problem that remained hanging on the server after some changes were made to the report itself, for some reason the parameters were not updated, the solution was to delete the report and reload it on the server.
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.
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.
From my C# code-behind I send a string value to my dataset. The data table also contains a field string type, which is dragged and dropped into Crystal Reports.
Now I need to divide that (string) value by some number, but strings can't be divided. So I need to convert the string to a value first - but I can't. No matter how I try to convert it always shows 0 on the report.
I created a formula called Euro:
NumericText({MYVALUE}) then ToNumber({MYVALUE})
And accessed it from another formula, EuroNum:
(If NumericText({Total}) then ToNumber ({Total}))
Then I created another field lets say TotalEuro where I did this in forumla, but it's always showing 0:
Euro/1.95
I used this formula:
If NumericText({VALUE}) Then ToNumber({VALUE}) / 1.955
Everything seems fine with Crystal Reports but I had problem in Visual Studio.
Even if this file is set up to copy everytime ,file somehow not copy changes to debug folder. So I manually moved this file to debug folder and everything was fine.
I am new to reporting services and to using the report viewer control in an aspx (C#). I am currently working on a project where I need to populate a report based on region. I am using SQL Express 2008 R2.
I have created a region parameter in the report, which is populated with a dataset using the following query:
SELECT RegionGUID, RegionDescription
FROM utRegion
This then creates a DropDownList with the available values, which I then use in my main report dataset to obtain my results based on the region selected.
The issue I have, is users in my application are assigned to regions and depending on who's logged into my application should restrict what regions are available via reporting services. I am able to pass parameters from my application via the report viewer to my report in reporting services, but when I try adding a parameter to my dataset that is used to populate the region DropDownList I get the following error when deploying:
The definition of the report '/Report name' is invalid
and the following error when previewing:
The report parameter 'RegionGUID' has a DefaultValue' or a ValidValue that depends on the report parameter "RegionGUID". Forward dependencies are not valid.
My query with the region parameter:
SELECT RegionGUID, RegionDescription
FROM utRegion
WHERE (RegionGUID = #RegionGUID)
I found the solution to my issue on the following site:
http://www.sqlservercentral.com/Forums/Topic306513-150-1.aspx
As stated by Jason Selburg in the above link, It seems that the order of the parameter list is important.
To make my application work I done the following:
Deleted my existing RegionGUID Parameter
Added a New Parameter called UserAssignedRegion with the Available Values of not specified and the visibility of hidden
Re-added my RegionGUID Parameter (visibility: visible) and set it to use the following query:
Query:
SELECT RegionGUID, RegionDescription
FROM utRegions
WHERE RegionGUID = #UserAssignedRegion
You should inspect the properties of the #RegionGUID parameter, specifically the DefaultValue or ValidValue tab. Either or both may depend on a dataset that uses the parameter itself in its query. You can't query a default or valid value for a parameter while using that parameter itself.
A typical query for available values would be:
SELECT DISTINCT RegionGUID -- For value
,RegionDescription -- For label
FROM utRegion
-- No where clause, you can't or need to use the parameter itself
The query for the default value may be the same (perhaps only use the First(...) value), NULL, or based on a different dataset (that also does not use the parameter itself)