Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 82.6k

how to get the message of SqlException error?

Nov 27 2021 2:13 PM

Hi

With this code below, i get the number of the SqlException error. But i want to see the full message instead of the error number.  For instance, instead of getting error number 207, i would like to get its equivalent message: "invalid column name". Is that possible?
try
{
..
}
catch (SqlException ex)
        {
         int a = ex.Number;
         ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Errornumber:' + '" + a + "');", true);
        }
Thanks


Answers (6)