是否有异常错误类值及其含义的列表?具体来说是sqlException
我正在使用数据库并捕获异常来检查各种条件。我不能简单地捕获 sqlException,因为它可能意味着很多事情,并且通常用于
catch (SqlException e)
{
if (e.Errors[0].Class == 14)
{
return 0;
}
else ........
检查特定情况。在此示例中,类别 14(至少据我所知)表示重复条目。不同的类意味着找不到服务器,或拒绝连接,或登录错误等。有谁知道在哪里可以找到这些错误类的列表?谷歌搜索这一点很困难,因为任何带有“class”的东西都会变得显而易见。
I'm working some with a database and catching exceptions to check for various conditions. I can't simply catch the sqlException, since it can mean a lot of things, and usually use
catch (SqlException e)
{
if (e.Errors[0].Class == 14)
{
return 0;
}
else ........
To check for specific cases. In this example, class 14 (at least as far as I can tell) signifies a duplicate entry. A different class means the server can't be found, or refusing the connection, or login error, etc. Does anyone know where a list of these error classes could be found? Googling this is difficult since anything with "class" in it turns up the obvious.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
严重性为 14 可能意味着很多事情:
要查看完整列表:
我怀疑您对 message_id 列比严重性列更感兴趣,因为它更具体一些。
A severity of 14 can mean a lot of things:
To see the full list:
I suspect you are more interested in the message_id column than the severity column, as that is a little more specific.
SqlError
类的Class
属性实际上指示了错误的严重性。有关错误类型,请查看Number
属性。您还可以使用消息
属性来获取描述错误的字符串。您可以在此处找到服务器错误消息列表。
The
Class
property of theSqlError
class actually indicates the severity of the error. For the type of error, look in theNumber
property. You can also use theMessage
property to get a string describing the error. You can find the list of server error messages here.