Professional Web Applications Themes

Error handling and custom error messages - Microsoft SQL / MS SQL Server

How can I get more informations about last error? I get the last error number with ERROR, but I don't know what is the source of error. For example when ERROR=547, I need to know ID of constraint that caused the error, so I can raise the custom error messages for each constraint (like in MS Access Project). Chedomir...

  1. #1

    Default Error handling and custom error messages

    How can I get more informations about last error? I get the last error
    number with ERROR, but I don't know what is the source of error. For
    example when ERROR=547, I need to know ID of constraint that caused the
    error, so I can raise the custom error messages for each constraint (like in
    MS Access Project).



    Chedomir



    Cedomir Markovic Guest

  2. #2

    Default Re: Error handling and custom error messages

    Don't raise custom user friendly error messages from SQL Server, raise them
    from your client application. Any errors are raised from SQL Server to your
    client application anyway (there is no way to prevent this) so why would you
    want to raise an extra error? In the client application you can p the
    error message (which has the constraint name in it) and raise a user
    friendly error to the end user based on that.

    For example:
    USE Northwind
    UPDATE employees SET birthdate = GETDATE()

    Will raise the following error message to the client:
    Server: Msg 547, Level 16, State 1, Line 1
    UPDATE statement conflicted with COLUMN CHECK constraint 'CK_Birthdate'. The
    conflict occurred in database 'Northwind', table 'Employees', column
    'BirthDate'.
    The statement has been terminated.

    From which you can get the database, table, column and constraint name if
    you need them.

    --
    Jacco Schalkwijk MCDBA, MCSD, MCSE
    Database Administrator
    Eurostop Ltd.


    "Cedomir Markovic" <chedomeunet.yu> wrote in message
    news:exY8E5rRDHA.1304TK2MSFTNGP11.phx.gbl...
    > How can I get more informations about last error? I get the last error
    > number with ERROR, but I don't know what is the source of error. For
    > example when ERROR=547, I need to know ID of constraint that caused the
    > error, so I can raise the custom error messages for each constraint (like
    in
    > MS Access Project).
    >
    >
    >
    > Chedomir
    >
    >
    >

    Jacco Schalkwijk Guest

Similar Threads

  1. Custom Error Messages
    By widaph1 in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: June 14th, 05:55 PM
  2. Custom Error Handling
    By Sergey Bogdanov in forum Macromedia ColdFusion
    Replies: 5
    Last Post: April 6th, 07:25 PM
  3. Custom Error messages in W2003
    By MIke in forum ASP Components
    Replies: 1
    Last Post: September 21st, 11:43 AM
  4. Replies: 1
    Last Post: September 12th, 10:22 AM
  5. Handling error messages
    By Itzik Ben-Gan in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: July 7th, 06:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139