Click here to Skip to main content
15,886,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have completed my project in visual studio 2010 ultimate and sql server 2008 r2 and its a web application.

I have crystal reports also in my project.

The path which i have given in my project is

C#
protected void btnPrint_Click(object sender, EventArgs e)
    {
        //  ReportDocument rDoc = new ReportDocument();
        //rDoc.Load("C:/Users/SUDESHNA/Documents/Visual Studio 2010/Projects/Inventory/SoldCrystalReport.rpt");
        //rDoc.SetParameterValue("@Category", ddlCategory.SelectedValue);
        //rDoc.SetDatabaseLogon("sa", "gariahat");
        //this.crystalReportViewer.ReportSource = rDoc;
        //this.crystalReportViewer.DataBind();
        //this.crystalReportViewer.Focus();
        //rDoc.Refresh();
        //rDoc.PrintToPrinter(1, true, 0, 0);

        ReportDocument rDoc = new ReportDocument();
        PrintDialog dialog1 = new PrintDialog();
        rDoc.Load(Server.MapPath("~/SoldCrystalReport.rpt"));
        rDoc.SetParameterValue("@Category", ddlCategory.SelectedValue);
        rDoc.SetDatabaseLogon("sa", "gariahat");
        dialog1.AllowSomePages = true;
        dialog1.AllowPrintToFile = false;
        if (dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            int copies = dialog1.PrinterSettings.Copies;
            int fromPage = dialog1.PrinterSettings.FromPage;
            int toPage = dialog1.PrinterSettings.ToPage;
            bool collate = dialog1.PrinterSettings.Collate;

            rDoc.PrintOptions.PrinterName = dialog1.PrinterSettings.PrinterName;
            rDoc.PrintToPrinter(copies, collate, fromPage, toPage);
        }
        rDoc.Dispose();
        dialog1.Dispose();


I have given Server.Mappath so that when it runs on server, it takes the path,

but at runtime, while clicking on print button i am getting the following error

C#
Server Error in '/' Application.
--------------------------------------------------------------------------------


Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack. 
  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: System.Runtime.InteropServices.COMException: Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.

Source Error: 


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 



[COMException (0x80041811): Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.]
   CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +90
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +259

[CrystalReportsException: Load report failed.]
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +322
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +851
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +78
   SoldItems.btnPrint_Click(Object sender, EventArgs e) +63
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9752490
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +196
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724


Kindly please tell what changes i have to make in my code?
So that it runs in server?

Please kindly help as my project is already in live, but the error is coming in crystal report printing part

Thanks
Sudeshna
Posted
Comments
Richard Deeming 19-May-15 9:38am    
That error message apparently means that Crystal can't find your report file.

Does the file SoldCrystalReport.rpt exist in the root folder of your application?
sudeshna from bangkok 19-May-15 9:42am    
yes soldcrystalreport.rpt is stored under wwwroot folder in server side.
sudeshna from bangkok 19-May-15 10:51am    
Hello can anyone tell me please what path should i gave?
my project is under my documents\microsoft visual studio 2010\projects\Inventory
under inventory the reports are there

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900