I'm pretty new the Crystal Reports (2nd day .. please bear with me) I've gotten the report to view, but im running into problems in the export ... I am trying to export the report to .pdf, and keep getting this error message: Error in file. Access to report
file denied. Another program may be using it. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Error in Report File: Access to report file denied. Another program may be using it. I am trying to write it temporarily to a file then we delete it ... here's the code
private void btnAdobe_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
// Export to pdf
TableLogOnInfo logonInfo1 = new TableLogOnInfo();
logonInfo1 = crystalReportPDF.Database.Tables["CR"].LogOnInfo;
logonInfo1.ConnectionInfo.ServerName = server;
logonInfo1.ConnectionInfo.DatabaseName = database;
logonInfo1.ConnectionInfo.UserID = user;
logonInfo1.ConnectionInfo.Password = password;
logonInfo1.TableName = "CR";
// Apply the connection information to the table.
crystalReportPDF.Database.Tables["CR"].ApplyLogOnInfologonInfo1);
//CrystalReportViewerPDF.DataBind();
string myFile = @"c:\tempCrystalPDFFile.pdf";
crystalReportPDF.ExportToDisk(ExportFormatType.PortableDocFormat, myFile);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/xls";
Response.WriteFile(myFile);
Response.Flush();
Response.Close();
System.IO.File.Delete(myFile);
//CrystalReportViewerPDF.Visible = true;
}
i'm not quite sure how to do that? could you please offer a suggestion? the code works fine as is on another computer, but not on this one?? thanks .. appreciate it
First of, you should really be placing your temp files in a folder other than c:\. Maybe also keep this folder name in your web.config. Anyway, to change permissions on a folder, right-click on the folder -> Properties -> Security tab -> Choose the ASP.NET
user and make sure this user has the "write" permissions property checked. LH
I don't know how your app is setup, but if it's setup for the default IIS settings, your code is executed under the ASP.NET user account and NOT by the user visiting your app. By default, the ASP.NET user account has no "write" permissions. LH
i got the user permission to work, sorry for the unnecessary question ... it can write and create the folder now. But now it's throwing me a login error? I cleaned the code up a bit ... thanks for the help ....
psinyc
Participant
1475 Points
293 Posts
Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 07, 2003 10:03 PM|LINK
private void btnAdobe_Click(object sender, System.Web.UI.ImageClickEventArgs e) { // Export to pdf TableLogOnInfo logonInfo1 = new TableLogOnInfo(); logonInfo1 = crystalReportPDF.Database.Tables["CR"].LogOnInfo; logonInfo1.ConnectionInfo.ServerName = server; logonInfo1.ConnectionInfo.DatabaseName = database; logonInfo1.ConnectionInfo.UserID = user; logonInfo1.ConnectionInfo.Password = password; logonInfo1.TableName = "CR"; // Apply the connection information to the table. crystalReportPDF.Database.Tables["CR"].ApplyLogOnInfologonInfo1); //CrystalReportViewerPDF.DataBind(); string myFile = @"c:\tempCrystalPDFFile.pdf"; crystalReportPDF.ExportToDisk(ExportFormatType.PortableDocFormat, myFile); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/xls"; Response.WriteFile(myFile); Response.Flush(); Response.Close(); System.IO.File.Delete(myFile); //CrystalReportViewerPDF.Visible = true; }Peter Iuvara, MCP
LordHits
Member
520 Points
104 Posts
Re: Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 08, 2003 04:19 AM|LINK
psinyc
Participant
1475 Points
293 Posts
Re: Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 08, 2003 02:02 PM|LINK
Peter Iuvara, MCP
LordHits
Member
520 Points
104 Posts
Re: Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 08, 2003 03:09 PM|LINK
psinyc
Participant
1475 Points
293 Posts
Re: Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 08, 2003 04:14 PM|LINK
Peter Iuvara, MCP
LordHits
Member
520 Points
104 Posts
Re: Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 08, 2003 04:35 PM|LINK
psinyc
Participant
1475 Points
293 Posts
Re: Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 08, 2003 04:53 PM|LINK
Peter Iuvara, MCP
psinyc
Participant
1475 Points
293 Posts
Re: Exporting the .pdf error: Access to report file denied. Another program may be using it.
Aug 08, 2003 09:56 PM|LINK
Peter Iuvara, MCP