Dear all I am working on an asp .net application (Webform) in which I am using crystal report for showing reports (with store procedure ).
In my application everything works fine including the reports. The real problem comes when I start clicking on the crystal report toolbar. If I click on any buttons on the crystal report tool bar like (Export, next page ...etc.) it is asking parameters again. Is there any way so that that the crystal report viewer does not ask the parameter that I have already given ?
ReportDocument r = new ReportDocument();
r.Load(Server.MapPath("~/Consumers/Reports/JobOrder.rpt"));
SqlParameter[] para= new SqlParameter[1];
para[0]= new SqlParameter("#OrderId",JobOrder);
dt=da.ExecuteQuery("sp_rpt_JobOrder",para);
if(dt.Rows.Count>0)
{
r.SetParameterValue("#OrderId", JobOrder);
r.SetDataSource(dt);
CrystalReportViewer1.ReportSource = r;
}
can some one help me? Highly appreciated.
its causing due to post back. so i removed
if (!Page.IsPostBack)
now its working fine for me.
Thank you.
Related
I have a form that prints some reports created with Crystal Report (13.030) and Visual Studio 2019. The printing of each report takes about 5/8 seconds. I have tried all the suggestions found on google, but have not solved anything. Since the reports are about 10m, the customer has to wait a long time before being able to continue.
I have read that it is a known problem, but I don't know how to fix it. I've been thinking about doing the prints in a BackgroundWorker, but I'm not sure if that's a good idea.
I checked the No printer in report box. This is one of my reports, which are all very similar. Am I wrong something?
ReportDocument myReport = new ReportDocument();
myReport.Load("myreport.rpt");
PrintLayoutSettings PrintLayout = new PrintLayoutSettings();
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = "PDF Creator"; // Any;
PageSettings pSettings = new PageSettings(printerSettings);
myReport.SetParameterValue("var1", "123");
myReport.SetParameterValue("var2", "ABC");
myReport.SetParameterValue("var3", "DEF");
myReport.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
myReport.Close();
I moved the prints to as many BackgroundWorkers, obviously everything is very fast, even if I don't know if it's the best solution.
When generating a RDLC report in a C#/WPF application, sometimes it hangs on render (call of render method doesn't return).
The report data comes from a C# object (which is filled in advance with data from a PostgreSQL database) so this issue is not SQL related.
I wonder:
How can I find out the reason?
Is there any way to enable the user to kill the report generation when it hangs?
Embedding the report generation in a using block (as seen in ReportViewer rendering hangs server after some executions) didn't solve the problem.
using (LocalReport report = new LocalReport())
{
report.ReportPath = #"C:\Path\To\MyReport.rdlc";
// Get the report data from db and fill it into MyReportData object.
MyReportData data = CreateReportData();
ReportDataSource headerDataSource = new ReportDataSource();
headerDataSource.Name = "HeaderDataSet";
headerDataSource.Value = data.Header;
report.DataSources.Add(headerDataSource);
// Add more data sources ...
// No report parameters are being used
report.Refresh();
pdfData = report.Render("PDF"); // here it hangs sometimes
}
As said above, the render-call hangs sometimes. After killing the application and generating exactly the same report again it works.
I'm trying to get a handle on the basics of report viewer control in a ASP.net Webforms project with C#. I'm using Adventure Work reports to get a feel for the basics.
I have a report called SalesOrderNumber under Report Parts on my SQL server
I just want to be able to view it at this point
if (!Page.IsPostBack)
{
// Set the processing mode for the ReportViewer to Remote
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
// Set the report server URL and report path
serverReport.ReportServerUrl =
new Uri("(!removed!");
serverReport.ReportPath =
"/Report Parts/SalesOrderNumber";
// Create the sales order number report parameter
ReportParameter salesOrderNumber = new ReportParameter();
salesOrderNumber.Name = "SalesOrderNumber";
salesOrderNumber.Values.Add("SO50750");
// Set the report parameters for the report
ReportViewer1.ServerReport.SetParameters(
new ReportParameter[] { salesOrderNumber });
I get back
The operation you are attempting on item '/Report Parts/SalesOrderNumber' is not allowed for this item type. (rsWrongItemType)
Assign full path like
"http://ReportServername/ReportFolderName/reportname.rdlc"
Make sure Report servername, ServerPath , ReportMode ,rendermode also
I know it's an old question but still I found - it needs an answer.
As per my view, we should first check report path that we have set.
The SSRS ReportPath setting must specify the full report path.
So if you want to access a report, you should set the below path,
http://YourServerName//ReportServer?/Foldername/ReportName
Note: if you've not created a folder on report server then no need to write FolderName. Directly write ReportName.
I would prefer to see below link if you want to access report server using URL.
Click here
Hope it would be helpful to others who are facing the same issue.
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.
I need some help.
Actually, I've read about this problem, and I thought that I've resolved it, but it keeps bothering me.
It's about different logins at developing and production enviroment.
This was supposed to be solution (EF and SQL Server):
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder((model.Connection as EntityConnection).StoreConnection.ConnectionString);
ConnectionInfo ci = new ConnectionInfo();
ci.ServerName = builder.DataSource;
ci.DatabaseName = builder.InitialCatalog;
ci.UserID = builder.UserID;
ci.Password = builder.Password;
report.SetDatabaseLogon(ci.UserID, ci.Password, builder.DataSource, ci.DatabaseName);
foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in report.Database.Tables)
{
TableLogOnInfo logon = tbl.LogOnInfo;
logon.ConnectionInfo = ci;
tbl.ApplyLogOnInfo(logon);
}
I extract login information from Entity Connection and apply it to all the tables in report. That should do the trick. I added SetDatabaseLogon() only to be sure, but that's not required.
Now, when I run report in production enviroment, report pops up a Database login screen showing CORRECT server name (production server), NOTHING next to database (that is my concern), proper username, and no password, asking to type in login information.
I type it in, but CR says "Login failed. Please try again". I mean WTF. I use the very same credential to connect to database with Management Studio.
I am using WPF viewer, BTW.
I am really stuck here, I've done some debugging, and connection info gets all the right data, so it must be report who is the culprit, but what should I do?
Any help would be appreciated. I hope somebody has stumbled to a same problem before me.
Regards
I had a problem with using "SetDatabaseLogon"
I changed by
report.DataSourceConnections[0].SetConnection("Servername","InitialCatalog", "UserID", "Password");
I hope this will helpful to someone.
Looking at the code on my Blog Post that does the same jobs, I can see a few differences:
Set tbl.Location to itself (this might be re initializing something internally - it didn't work without it).
Put your code in a method that you can re-call to handle sub reports:
My version never needs to call report.SetDatabaseLogon
Other than that they're basically identical.
Code:
void SetConnection(ReportDocument rd, crConnectionInfo ci)
{
foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in rd.Database.Tables)
{
TableLogOnInfo logon = tbl.LogOnInfo;
logon.ConnectionInfo = ci;
tbl.ApplyLogOnInfo(logon);
tbl.Location = tbl.Location;
}
if (!rd.IsSubReport) {
foreach {ReportDocument sd in rd.SubReports) {
SetConnection(sd,ci)
}
}
}
(Note: Just hand coded this, so check it before you use it).
This works on the VS2008 version of crystal reports (forget what it was called).
EDIT: One other thing, in my connection initialization, there are a couple of extra properties set:
ci.Type = ConnectionInfoType.SQL;
ci.IntegratedSecurity = false;
It was totally stupid problem, and i solved it by chance. Installation of Crystal Reports on my desktop computer was crooked or something, so whenever I edited something with database expert (add some tables, for example), it spoiled my report. All I did is use "set database location" option on my laptop, and now my reports run flawlessly.