Hello,
I am trying to do Exception Handling in the C# code(.NET environment)for an Web Application. I want to catch a Crystal Report Exception(Formula exception) by using "try-catch" block.
But I am not able to catch the exception. Surprisingly, the code is not entering into the catch block at all.I am getting the usual error page (which we get without doing the exception handling).
It will of great help for me if someone can guide me on this.
For your reference I am attaching the piece of code, I am using.
Note: This is happening for all types of CrystalReport exceptions.
Regards,
Nabin
Button1_Click(object sender, System.EventArgs e)
{
try
{
string sConnectionString = ConfigurationSettings.AppSettings["SCMSdsn"];
m_oConn = new SqlConnection(sConnectionString);
m_oAdapter = new SqlDataAdapter("spr_Rpttest", m_oConn);
m_oAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
m_oAdapter.SelectCommand.Parameters.Add(new SqlParameter("@User",SqlDbType.NVarChar,30));
m_oAdapter.SelectCommand.Parameters["@User"].Value = Testbox1.Text;
dsMydataset oDS = new dsMydataset();
m_oAdapter.Fill(oDS, tbl_mytable);
m_oReportDocument.SetDataSource(oDS);
//m_oReportDocument is declared as, "protected CrystalReport1 crReportDocument=new CrystalReport1();"
CRV.ReportSource = m_oReportDocument;
//CRV is declared as, "protected CrystalDecisions.Web.CrystalReportViewer CRV";
}
catch(CrystalDecisions.CrystalReports.Engine.FormulaException e)
{
lblMessage.Text="Incorrect Formula used.";
}
}