是否有异常错误类值的列表,他们是什么意思?具体的SQLException [英] Is there a list of exception error class values and what they mean? Specifically sqlexception

查看:404
本文介绍了是否有异常错误类值的列表,他们是什么意思?具体的SQLException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用数据库部分和捕获异常检查各种条件。我不能简单地赶上的SQLException,因为这可能意味着很多东西,而且通常使用

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 ........

要检查具体案例。在这个例子中,14类(至少据我可以告诉)表示一个重复的条目。不同级意味着服务器无法找到,或拒绝连接,或登录错误等有谁知道这些错误类的列表可以发现?谷歌搜索,这是困难的,因为与阶级任何东西它变成了明显的。

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.

推荐答案

SQLERROR 类的属性实际上表明错误的严重程度。对于错误类型,看在 编号 财产。您也可以使用 消息 属性来获取描述错误的字符串。你可以找到服务器错误消息列表这里

The Class property of the SqlError class actually indicates the severity of the error. For the type of error, look in the Number property. You can also use the Message property to get a string describing the error. You can find the list of server error messages here.

这篇关于是否有异常错误类值的列表,他们是什么意思?具体的SQLException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆