I get javascript errors when adding a report to an ASPX page. When clicking the view button I get javascript errors.
A simple report with a set of parameters throws the following javascript error. I'm using the local processing mode with a dynamically generated set of data sources and parameters. When I load the page without parameters, I see the following error.
And when I add the parameters, the following exceptions will show up.
This is the code to generate the report. The backend processing runs successfully, but when it comes to the client-side processing, it fails to display the report component.
ReportViewer1.Reset();
ReportViewer1.Visible = true;
ReportViewer1.EnableTelemetry = false;
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath($"~/Reports/{_reportName}");
foreach (var param in ReportParameters.Where(r => r.Hidden))
ReportViewer1.LocalReport.SetParameters(new ReportParameter(param.Name, param.DefaultValue));
foreach (var dataset in DataSets)
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource(dataset, GetReportData(dataset)));
ReportViewer1.LocalReport.Refresh();
Update:
I just noticed this issue only happens in Chrome. I've been able to open the report in IE successfully.
Apparently, this issue happens when a previous version of SSRS still cached in the IIS Express or IIS. A system restart resolved the issue.
Related
I'm trying to design an rdlc report viewer in an asp.net project, the report works if no parameters are set, but when I set the parameters the below error is displayed:
The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.
It seems that the error is in the rdlc file version, anyone knows how to solve this ?
This is the code the report viewer page:
if (!Page.IsPostBack)
{
var app = (Pcr.Models.Appointment)Session["app"];
ReportParameter[] parameters = new ReportParameter[1];
parameters[0] = new ReportParameter("FullName", app.Name);
parameters[1] = new ReportParameter("PhoneNumber", app.PhoneNumber.ToString());
ReportViewer1.LocalReport.SetParameters(parameters);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.ShowParameterPrompts = false;
ReportViewer1.ShowPromptAreaButton = false;
}
And this is the report definition:
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
Try to fix this line. Your code will break as you need a table with two parameters, not one.
ReportParameter[] parameters = new ReportParameter[2];
Other than that, check the question here: SSRS report definition is newer than Server for more information on the specific error.
I have 2 parameters (Detail, Summary) that I have created in a Crystal Report. The report is called from c# in a Windows Forms application. I am trying to pass the appropriate value to each parameter at runtime so the report can make some decisions based on the values. I have read many articles regarding this and I think I am using the best method to accomplish this?
This is the simple code I have implemented after the report has been loaded and before the SetDataSoruce has been set:
crReportDocument.SetParameterValue("DetailView", false);
crReportDocument.SetParameterValue("SummaryView", true);
For some reason the values are not getting to the report as the report is always prompting for the values to be set when it runs.
Everything else about the report works correctly.
I would appreciate any light someone can shed on this matter as it seems to be a simple task to do?
Actually the problem was code placement. I was populating the parameters in the wrong place of code execution:
This is how I had it when it was not working:
crReportDocument.SetParameterValue("FromDate", dtmFromDate);
ReportViewer reportViewer = new ReportViewer();
reportViewer.ReportSource = crReportDocument;
To resolve I moved the code around as follows:
ReportViewer reportViewer = new ReportViewer();
reportViewer.ReportSource = crReportDocument;
crReportDocument.SetParameterValue("FromDate", dtmFromDate);
That's all it took to get it to work correctly.
Let me know if it does not work for you.
The problem is that the parameter must be passed using format {?PARAMETER}.
It works.
crReportDocument.SetParameterValue("{?DetailView}", false);
crReportDocument.SetParameterValue("{?SummaryView}", true);
I am able to display the report on web browser.My problem is, when I use the toolbar(such as export button,print button,find button and so on) of crystal report I am facing the parameter missing error over web browser.Please help me how to shut out this issue in asp.net platform by using c#.
Thanks in Advance.
You need to store/persist your reportdocument object in session variables
if (!Page.IsPostBack)
{
rpt = new ReportDocument();
Session["report"] = rprt; // store the report in the Session
}
else
{
rpt = (ReportDocument)Session["report"];
}
and here is the explanation
http://scn.sap.com/community/crystal-reports-for-visual-studio/blog/2011/04/25/why-should-i-store-reports-object-in-httpsession
I am loading a report in a SSRS Report in a ASPX page and whenever I try to load it it gets stuck on Loading. Now, initially I was inputting the parameters directly into the texboxes provided by the SSRS applet, and the report loaded without issue. Now I am inputting the parameters directly through C# code and it gets stuck in that loading screen I mentioned. I checked the parameters (set the code to true) and it showed me that the parameter fields were filling up correctly with the data I was passing. This is the codebehind:
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://servername:80/ReportServer_MSSQLSERVER2012"); // Report Server URL
ReportViewer1.ServerReport.ReportPath = "/Test/Report2"; // Report Name
ReportViewer1.ShowParameterPrompts = true;
ReportViewer1.ShowPrintButton = true;
Microsoft.Reporting.WebForms.ReportParameter[] Param = new Microsoft.Reporting.WebForms.ReportParameter[4];
Param[0] = new Microsoft.Reporting.WebForms.ReportParameter("ID", Convert.ToString(Session["aCode"]));
Param[1] = new Microsoft.Reporting.WebForms.ReportParameter("IDATE", "02/02/2002");
Param[2] = new Microsoft.Reporting.WebForms.ReportParameter("FDATE", "11/06/2013");
Param[3] = new Microsoft.Reporting.WebForms.ReportParameter("Acct", "2005");
ReportViewer1.ServerReport.SetParameters(Param);
//ReportViewer1.ServerReport.Refresh();
I am manually passing the last values to see how its responding. It still doesn't load even when the Refresh command is uncommented. If anyone can shed some light I'd greatly appreciate it
Seems the mistake was mine. I was putting that code under the "Load" process, and I decided to put the code under a Button press. With the button press everything displays correctly, and if I decide to add it under Page_Load I must use the "if isPostback" type of code to stop an endless loop.
How to create parametrized reports using microsoft report viewer?
Put more details in your question, but as i understand the MSDN ReportViewer Controls will be very nice to you learn more by yourself.
Check out http://www.youtube.com/watch?v=sXJmRHgSAS8&feature=related
For one thing, I would avoid the Microsoft report viewer control. Just use a browser control, and browse to the report, passing in the parameters in the URL like you would when using a browser.
This is much better for many reasons.
The MS Report Viewer Control has a lot of bugs that you will be stuck with.
The browser and the report viewer render the reports differently (slightly) such as with margins etc. So you will have to tweak most of your reports if you ever switch to a web application and need to use the browser to access reports. This brings me to the next issue . . .
If you ever need to go to a web application, you will need to reimplement how you call reports, pass parameters, etc. instead of just using the browser functionality you already have created (you access the reports differently using the control vs. using a browser)
Otherwise, if you truly want to use the Report Viewer control, here is a sample (using .NET 2.0):
ReportViewer rvReportViewerControl = new ReportViewer();
rvReportViewerControl.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
rvReportViewerControl.ServerReport.ReportServerUrl = new Uri("http://<SERVERNAME>/ReportServer");
rvReportViewerControl.ServerReport.ReportPath = "<FOLDER PATH TO REPORTS>");
rvReportViewerControl.ShowParameterPrompts = false;
Microsoft.Reporting.WinForms.ReportParameterInfoCollection rpInfoCollection = rvReportViewerControl.ServerReport.GetParameters();
if (rpInfoCollection.Count > 0)
{
List<ReportParameter> paramList = new List<ReportParameter>();
foreach (ReportParameterInfo reportParameter in rpInfoCollection)
{
string parameterName = reportParameter.Name.ToString();
string parameterValue = "";
bool isParameterVisible = reportParameter.Visible;
paramList.Add(new ReportParameter(parameterName, parameterValue, isParameterVisible));
}
rvReportViewerControl.ServerReport.SetParameters(paramList);
}
rvReportViewerControl.RefreshReport();
This site has a lot of useful information.