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 be of great help for me, if someone can help me on this.
Thanks,
Nabin
For the reference, I am attaching the piece of code, I am using.
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.";
}
}
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 be of great help for me, if someone can help me on this.
Thanks,
Nabin
For the reference, I am attaching the piece of code, I am using.
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.";
}
}