Link to home
Start Free TrialLog in
Avatar of starlite551
starlite551Flag for India

asked on

Exception While Generating a Report

I am getting the following exception message while generating a pdf document from a crystal report :
Error Message : Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
 
protected void Export_Report()
    {
        ReportDocument Rpt = getReportDocument();

        Response.Buffer = false;

        Response.ClearContent();
        Response.ClearHeaders();


    }
    protected ReportDocument getReportDocument()
    {
        view_report();
        return Rpt;
    }
    public void view_report()
    {
        //Status =drpStatus.

        Rpt = new ReportDocument();
       
        string ReportPath = "~/Insurance/Reports/Crystal_Report/InsuranceAnnexure.rpt";

        dsInsuranceApplicant dsInsApp = new dsInsuranceApplicant();
        string cs = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString().Trim();
        OracleConnection conn = new OracleConnection(cs);
        conn.Open();
        DataSet dsLoanDt = insObj.GetLoanAmount(hdnApplicantId.Value);
        if (dsLoanDt.Tables[0].Rows.Count>0)
        {
            dsInsApp.Tables["LOAN_DETAILS"].Merge(dsLoanDt.Tables[0]);   
        }
        
        string StrQuery;
        StrQuery = "";
        if (hdnApplicantId.Value != "")
        {
            StrQuery = "SELECT * FROM VWINSURANCE_REPORT WHERE APP_AID = '" + hdnApplicantId.Value + "'";
            da = new OracleDataAdapter(StrQuery, conn); ;
        }
        else
        {
            StrQuery = "SELECT * FROM VWINSURANCE_REPORT";
        }
        OracleCommand cmd = new OracleCommand(StrQuery, conn);
        cmd.CommandType = CommandType.Text;
        da = new OracleDataAdapter(cmd);
        da.SelectCommand = cmd;

        da.Fill(dsInsApp.Tables["VWINSURANCE_REPORT"]);
        if (dsInsApp.Tables["VWINSURANCE_REPORT"].Rows.Count != 0)
        {           
            Rpt.Load(Server.MapPath(ReportPath));
            Rpt.SetDataSource(dsInsApp);            
        }
        else
        {
            string strScript1;
            strScript1 = "<script>";
            strScript1 = strScript1 + "alert('No Record Available.');";
            strScript1 = strScript1 + "</script>";
            //Page.RegisterStartupScript("ClientScript", strScript1.ToString());
            ClientScript.RegisterStartupScript(this.GetType(), "clientscript", strScript1.ToString());
        }
    }

Open in new window


Please help me asap..
Avatar of starlite551
starlite551
Flag of India image

ASKER

Here  dsInsuranceApplicant is a strongly typed DataSet Added in the Solution Explorer using Add New Item Option..
Avatar of Todd Gerbert
What line is throwing the exception?
Avatar of Mike McCracken
Mike McCracken

On line 40 you open da and don't have a similar line in the other part of the IF

You then open another da on line 48.  Perhaps delete line 40

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of starlite551
starlite551
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tell me the exact cause and I`ll accept it as a solution.. Thanks in advance.. :)
I got the solution