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

Rijwan AnsariPosted Nov 28, 2021, 6:18 AM
Vinitha TPosted Dec 6, 2021, 3:44 PM
Instead of storing ex.Number in int, store ex.Message in string to get error message.
ex.Number identifies type of Error.
To get detailed error message:
try{
}
catch(SqlException ex)
{
string a = ex.Message.ToString();
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Errornumber:' + '" + a + "');", true);
}
Valerie MeunierPosted Nov 28, 2021, 9:56 PM
Sachin SinghPosted Nov 28, 2021, 4:44 AM