使用ExecuteNonQuery()时从SQLite检索错误代码 [英] Retrieving error codes from SQLite when using ExecuteNonQuery()

查看:163
本文介绍了使用ExecuteNonQuery()时从SQLite检索错误代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的C#项目中,我正在使用从

In my C# project, I'm using System.Data.SQLite.dll downloaded from CodeProject.

我的问题是按标题显示的-调用SqliteCommand.ExecuteNonQuery()函数后如何获取错误代码?

My problem is as per the title - how to get the error codes after calling SqliteCommand.ExecuteNonQuery() function?

此处所示的错误代码,例如SQLITE_CONSTRAINT, SQLITE_BUSY, SQLITE_LOCKED.

Error codes such as SQLITE_CONSTRAINT, SQLITE_BUSY, SQLITE_LOCKED as shown here.

推荐答案

使用Exception.StackTrace或SQLiteException.ErrorCode

use the Exception.StackTrace or the SQLiteException.ErrorCode

try
{

}
catch(SQLiteException ex)
{
    string code = ex.ErrorCode;
}

这篇关于使用ExecuteNonQuery()时从SQLite检索错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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