locked
The full SqlException.Number list ? RRS feed

  • Question

  • User-1603557471 posted

     Hello there,

    We would like to obtain a more specific error in db operation (sql server express 2005) via the SqlException.Number. For example:

    try
    {
    cn.Open();
    // update record
    }
    catch(SqlException ex)
    {
    if (ex.Number == 4060)
    {
    // invalid db
    }
    else if (ex.Number == 18452)
    {
    // login failed
    }
    finally
    {
    cn.Close();
    }

    Where can the full SqlException.Number list be obtained? Also, is there a DataAccessErrorType property list for SqlException.Number (eg. DataAccessErrorType.SqlError)?

    Thanks,

    Ben

    Monday, July 5, 2010 11:09 AM

Answers

  • User-324533553 posted


    check this out

    http://forums.asp.net/t/312734.aspx

    or

    The Numbers come from the master.dbo.sysmessages table, one of the ways that I find out what number matches what message is be using a query like this:

    SELECT *
    FROM master.dbo.sysmessages

    or

    http://support.microsoft.com/kb/110769

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 5, 2010 12:16 PM

All replies

  • User-324533553 posted


    check this out

    http://forums.asp.net/t/312734.aspx

    or

    The Numbers come from the master.dbo.sysmessages table, one of the ways that I find out what number matches what message is be using a query like this:

    SELECT *
    FROM master.dbo.sysmessages

    or

    http://support.microsoft.com/kb/110769

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 5, 2010 12:16 PM
  • User-1603557471 posted

    Many thanks :-) 

    Monday, July 5, 2010 10:18 PM
  • User464495919 posted
    Go to http://msdn.microsoft.com/en-us/library/cc645603.aspx for a full reference of the error numbers.

    Wednesday, October 2, 2013 2:07 AM