M
Michelle Stone
Hi
I successfully exported a Crystal Reports report to .pdf
format on my development machine. I even attempted the
same on another computer in our office, before I went
over to our client place.
But when deploying the same on the client machine I was
dismayed to get the following error
CrystalDecisions.CrystalReports.Engine.LoadSaveReportExcep
tion: Error in File C:\DOCUME~1\RAED\ASPNET\LOCALS~1
\Temp\temp_26e6fe05-5b3c-4b25-9645-3365fce08b81.rpt:
Access to report file denied. Another program may be
using it.
I am cut-pasting the code used for exporting below.
Please advise.
Extra information relevant to the scenario
1. I added the Program OUTPUT and Program CONTENT in the
web setup project
2. Added the merge modules as listed on the web site of
Crystal Decisions
Code used for exporting:
{
RSalesReportSet ds = new RSalesReportSet ();
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@IDInsuranceCompany"].Value =
insuranceCompanyCombo.SelectedValue;
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@IDBroker"].Value = brokerCombo.SelectedValue;
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@IDBranch"].Value = branchCombo.SelectedValue;
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@dateFrom"].Value = "'" + fromEdit.Text + "'";
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@dateTo"].Value = "'" + toEdit.Text + " 23:59:59'";
sqlSalesReportDataAdapter.Fill (ds, "TPolicy");
// Set up the Report
RSalesInsuranceCompanyBrokerBranch myReport = new
RSalesInsuranceCompanyBrokerBranch ();
myReport.SetDataSource (ds);
// Set up the parameters within the report
myReport.SetParameterValue ("dateFrom",
fromEdit.Text);
myReport.SetParameterValue ("dateTo",
toEdit.Text);
// Now export to .pdf file
CrystalDecisions.Shared.DiskFileDestinationOptions
disOpts = new
CrystalDecisions.Shared.DiskFileDestinationOptions ();
myReport.ExportOptions.ExportDestinationType =
CrystalDecisions.Shared.ExportDestinationType.DiskFile;
myReport.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
;
disOpts.DiskFileName = @"c:\Temp.pdf";
myReport.ExportOptions.DestinationOptions =
disOpts;
myReport.Export
();
Response.ContentType="application/pdf";
Response.Write
("<script language=javascript>window.open
('c:/Temp.pdf', 'Report', 'fullscreen=no, toolbar=yes,
menubar=yes'); </script>");
}
I successfully exported a Crystal Reports report to .pdf
format on my development machine. I even attempted the
same on another computer in our office, before I went
over to our client place.
But when deploying the same on the client machine I was
dismayed to get the following error
CrystalDecisions.CrystalReports.Engine.LoadSaveReportExcep
tion: Error in File C:\DOCUME~1\RAED\ASPNET\LOCALS~1
\Temp\temp_26e6fe05-5b3c-4b25-9645-3365fce08b81.rpt:
Access to report file denied. Another program may be
using it.
I am cut-pasting the code used for exporting below.
Please advise.
Extra information relevant to the scenario
1. I added the Program OUTPUT and Program CONTENT in the
web setup project
2. Added the merge modules as listed on the web site of
Crystal Decisions
Code used for exporting:
{
RSalesReportSet ds = new RSalesReportSet ();
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@IDInsuranceCompany"].Value =
insuranceCompanyCombo.SelectedValue;
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@IDBroker"].Value = brokerCombo.SelectedValue;
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@IDBranch"].Value = branchCombo.SelectedValue;
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@dateFrom"].Value = "'" + fromEdit.Text + "'";
sqlSalesReportDataAdapter.SelectCommand.Parameters
["@dateTo"].Value = "'" + toEdit.Text + " 23:59:59'";
sqlSalesReportDataAdapter.Fill (ds, "TPolicy");
// Set up the Report
RSalesInsuranceCompanyBrokerBranch myReport = new
RSalesInsuranceCompanyBrokerBranch ();
myReport.SetDataSource (ds);
// Set up the parameters within the report
myReport.SetParameterValue ("dateFrom",
fromEdit.Text);
myReport.SetParameterValue ("dateTo",
toEdit.Text);
// Now export to .pdf file
CrystalDecisions.Shared.DiskFileDestinationOptions
disOpts = new
CrystalDecisions.Shared.DiskFileDestinationOptions ();
myReport.ExportOptions.ExportDestinationType =
CrystalDecisions.Shared.ExportDestinationType.DiskFile;
myReport.ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
;
disOpts.DiskFileName = @"c:\Temp.pdf";
myReport.ExportOptions.DestinationOptions =
disOpts;
myReport.Export
();
Response.ContentType="application/pdf";
Response.Write
("<script language=javascript>window.open
('c:/Temp.pdf', 'Report', 'fullscreen=no, toolbar=yes,
menubar=yes'); </script>");
}