SSRS Report Stuck on Loading - c#

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.

Related

Parameter value in Access report dialog

so i'm trying to automate some reporting in Access 2013. When I run a report I get a dialog asking for a parameter (Enter Plant:), something like this.
What I want is to run this code without asking the query for a plant name. The code works but if I run it, it pops a dialog asking for a Plant name, and if I type the Plant Name it runs and saves the pdf file just like I want to. The report in Access works by giving a different Plant name and it outputs a different report depending on the given Plant. My idea is to put this code on a loop and in each iteration pass a different plant name and save a different new file. But it always pop a dialog asks for a plant name to be added manually.
Microsoft.Office.Interop.Access.Application oAccess = null;
// Start a new instance of Access for Automation:
oAccess = new Microsoft.Office.Interop.Access.Application();
// Open a database in exclusive mode:
oAccess.OpenCurrentDatabase(
"route DB", //filepath
true //Exclusive
);
//This doesnt work
// oAccess.DoCmd.SetParameter("[Enter Plant:]", "Arlington");
oAccess.DoCmd.OpenReport(
"06 - Security Report - Plants",
AcView.acViewReport,
"qry Security Report - Plant",
//This doesnt work either, still asks me for a plant name
"[Enter Plant:] ='Arlington'",
AcWindowMode.acWindowNormal
);
//If I give the plant name to the dialog it works correctly en saves a pdf file wit the report
oAccess.DoCmd.OutputTo(
AcOutputObjectType.acOutputReport,
System.Reflection.Missing.Value,
"PDF Format (*.pdf)",
"route to save file",
false,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
AcExportQuality.acExportQualityPrint
);
oAccess.Quit();
I can access the query but unfortunately i cant modify it, also its pretty long thats why I will not be able to show it(looks like it was created by a the Access Wizard, so its preeety long) though here its an example where the asked parameter is being used:
AND ((Signers.Location)=[Enter Plant:])
This parameters is in the query like 40+ times.
Any ideas? Thanks in advance!
I have faced this many times at work, and the solution I used most often is to have a TextBox in a form somewhere that can be referenced directly.
AND ((Signers.Location)=[Forms]![frmMyForm]![txtMyPlantTextBox])
NOTE: You would need to have the form open and data entered into the TextBox before you run the query.

WebForms Report Viewer JavaScript Error

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.

Setting/Passing a Value to a Parameter to a Crystal Report in c# is Not Working

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);

ASP.NET (C#) crystal reports export fails with "Method not found.."

as I said in title I have issue when I try to export crystal report to PDF, or anything like that, also when I try to print it I am having same issue, before anything I will post you screenshot to explain it more detailed:
I loaded report with my data from database and everything looks fine, reports is opened I can see my data, but when I try to export it to pdf or to print it I am seeing that Error, I've been trying for few hours to solve it, but unfortunately I couldn't make it working..
I have to mention, that I did next thing before this:
I set EnableDatabaseLogonPromt to False because before I did that, everytime I tried to do print or export I received this popup (so should I leave it setted to false to avoid this popup?)
HERE IS MY CODE:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var x = Server.MapPath("~");
int playerId = Convert.ToInt32(Request.QueryString["playerID"]);
PlayersDataSet players= new PlayersDataSet ();
PlayersDataSet.PlayersTableDataTable playersDT = new PlayersDataSet.PlayersTableDataTable ();
var player= Players.Data.Services.DAPlayers.GetByPlayerId(playerId);
string clubname= Players.Data.Services.DAPlayers.GetClubNameByClubID(Convert.ToInt32(player.ClubID));
playersDT.AddPlayersTableRow(player.FirstName, player.LastName, player.IDNUMBER, clubname, player.Photo, player.IDSerialNumber.ToString());
players.Tables["PlayersTable"].Merge(playersDT);
rpt_Players RPT = new rpt_Players ();
RPT.SetDataSource(players);
CrystalReportViewer1.ReportSource = RPT;
}
Any kind of help would be great!
Thank you guys,
Cheers
Its stupid to answer my own questions but after hours and hours of searching and trying many different things, I've found that this is a solution: remove this condition : if(!ispostback){} and everything will be fine with exporting etc.. :)

How to block the enter parameter value prompt from crystal report? [duplicate]

I am having a terrible problem with crystal report 2010 for .net 4.0 (I am using the fixed 13.0.1 version but 13.0.4 is released). No matter which way I try, I am always getting a prompting dialogue box to input my one parameter value the first time.
CrystalReportViewer1.ReportSource = CustomerReport1;
CustomerReport1.Database.Tables[0].SetDatasource ( this.dataset);
CustomerReport1.SetParameterValue("PathLocation", Location.Text);
CustomerReport1.Parameter_PathLocation.CurrentValues.Add(Location.Text) // to be safe using CS 2010 for .net 4
CrystalReportViewer1.ReuseReportParametersOnRefresh = true; // to prevent from showing again and again.
I also tried this:
CustomerReport1.Database.Tables[0].SetDatasource ( this.dataset);
CustomerReport1.SetParameterValue("PathLocation", Location.Text);
CrystalReportViewer1.ReportSource = CustomerReport1;
And this:
CustomerReport1.Database.Tables[0].SetDatasource ( this.dataset);
CustomerReport1.Parameter_PathLocation.CurrentValues.Add(Location.Text)
CrystalReportViewer1.ReportSource = CustomerReport1; // the parameter in the report has Optional Parameter = false, Static , Multiple Value = false .
Can anyone please help? I am getting frustrated with this. It worked in previous versions, but now I am getting this prompt box.
Thank you.
Finally found the solution. It doesn't prompt if we set the DataSource after the ParameterValue.
So anyone of those will work if we put them in this order:
// First, call SetParameterValue. Then, call SetDatasource.
CustomerReport1.SetParameterValue("PathLocation", Location.Text);
CustomerReport1.Database.Tables[0].SetDatasource(this.dataset);
CrystalReportViewer1.ReportSource = CustomerReport1;
Thank you all.
create the parameter but do not assign it a formula using selection formula -> record. Apply this parameter from vb or c#.net IDE by creating a text box,a label and a button. Put the selection formula on click button procedure.

Categories

Resources