on 06-12-2012 4:49 AM
The following error occurred:
Error in File C:\Windows\TEMP\AC01 {6BDA6012-685C-467C-BB99-E2BE77C5D3F1}.rpt: Access to report file denied. Another program may be using it.
run in IIS in win 7 got this error,
run in visual studio can export pdf successfully
After searched, it said remove impersonate = true , however another function for exporting Excel need this
protected void ExportPDFButton_Click(object sender, EventArgs e)
{
ReportDocument objRpt = new ReportDocument();
string reportPath = @"C:\sap\Addon\CPS_Crystal800\CrystalReports\AC01.rpt";
objRpt.Load(reportPath);
int projindex = ddlProject.SelectedIndex;
string projValue = ddlProject.Items[projindex].Value.ToString();
//objRpt.SetDatabaseLogon("sa", "compass2008", "10.1.1.42", "PAY800");
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Tables CrTables;
//Table CrTable;
crConnectionInfo.ServerName = "X.X.X.X";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "XXX";
crConnectionInfo.DatabaseName = "XXX";
objRpt.SetParameterValue(0, projValue);
objRpt.SetParameterValue(1, projValue);
CrTables = objRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
ExportOptions exportOpts = new ExportOptions();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
exportOpts = objRpt.ExportOptions;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
diskOpts.DiskFileName = "C:\\ACIReport.pdf";
exportOpts.DestinationOptions = diskOpts;
//objRpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
objRpt.ExportToHttpResponse(exportOpts, this.Page.Response, true, "ACI01" + DateTime.Now.ToString("yyyyMMdd"));
}
Does the account used by IIS have access to the root of C: ? I kind of hope not!
Try changing it to the TEMP folder, see if it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.