on 06-29-2010 8:14 PM
I have searched on Google and all over this forum and none of the solutions have fixed my problem.
Crystal Version: Crsytal.Net for Visual Studio.Net 2005
Server: Windows Server 2003
Error:
Access denied. Error in File C:\WINDOWS\TEMP\JuryDutyReport {D6296178-3E72-483E-B876-2DFC03D00841}.rpt: Access to report file denied. Another program may be using it.
When I run my app locally through the Web Server that comes with ASP.Net, everything is fine, it is only when I deploy the application to the Windows 2003 Server that I get the error.
I'm using impersonation in my ASP.Net application. I have given that domain user full access to 'C:\Windows\Temp'', the export folder and even the folder where the Crystal Report resides on the Server. When I run the application on the Web Server, I actually see the ".rpt" get created in the "C:\Windows\Temp" folder but yet it still says there is a permissions error.
What is bizarre is that the code below that just sends the file to the printer automatically works:
private void PrintJuryDutyReport(DataSet ds)
{
//create report document
ReportDocument crDoc = new ReportDocument();
//load, set datasource and print options
crDoc.Load(Server.MapPath("~/Reports/JuryDutyReport.rpt"));
crDoc.SetDataSource(ds); //set datasource
crDoc.PrintOptions.PrinterName = ddlPrinters.SelectedValue.ToString(); //set printername
crDoc.PrintOptions.PaperOrientation = PaperOrientation.Portrait; //set paper orientation
crDoc.SetParameterValue("ParamUsername", User.Identity.Name); //set parameter
crDoc.PrintToPrinter(1, false, 0, 0); //send to printer
}
I have to change the code to export to a PDF and this code doesn't work:
private void PrintJuryDutyReport(DataSet ds)
{
//report document
ReportDocument crDoc = new ReportDocument();
string myfile = @"G:\COPFS\COPFSPROD\ReportsTemp\MyPDF.pdf";
//load, set datasource and print options
crDoc.Load(Server.MapPath("~/Reports/JuryDutyReport.rpt"));
crDoc.SetDataSource(ds); //set datasource
crDoc.SetParameterValue("ParamUsername", User.Identity.Name); //set parameter
//export through http
//
crDoc.ExportToDisk(ExportFormatType.PortableDocFormat, myfile);
crDoc.Close();
crDoc.Dispose();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/pdf";
Response.AppendHeader("content-disposition", "attachment; filename=" + myfile);
Response.WriteFile(myfile);
Response.Flush();
Response.Close();
}
Any help is greatly appreciated as I have to present this to end users tomorrow.
There is a property to open the report as a Temp file, use it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tengo el mismo error... como lo solucionaste?? De antemano mil gracias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.