Smart way to get unique index name from SqlException message?
Is there there any smart/best way to get the unique index name from SqlException
message? like 开发者_Python百科the following:
Cannot insert duplicate key row in object 'partners.Partner' with unique index 'IX_Partner_SerialId'. The statement has been terminated.
I need to get IX_Partner_SerialId
without having to manipulate the exception message string? something like a variable in the exception object?
Unfortunately not.
You will have to parse message text. You can find the message texts and error numbers by querying
SELECT * FROM SYSMESSAGES
精彩评论