第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 C# CLI 應(yīng)用程序中檢查 SQLiteException “extended”

在 C# CLI 應(yīng)用程序中檢查 SQLiteException “extended”

C#
泛舟湖上清波郎朗 2021-12-05 16:46:58
我編寫了一個支持 SQLite 的 CLI 應(yīng)用程序。為此,我使用SQLite 開發(fā)團(tuán)隊的 NuGet 包“ System.Data.SQLite ”。一切正常,但是如果出現(xiàn)異常,如何檢查“擴(kuò)展結(jié)果代碼(查看第 5 點) ”?我可以訪問 Enum SQLiteErrorCode 中的所有錯誤代碼,但在“ex.ResultCode”中始終是主要結(jié)果代碼(查看第 4 點)。例如try{    // DB actions ....}catch (SQLiteException ex){    // This is what i want because is clear and easy to read    if (ex.ResultCode == SQLiteErrorCode.Constraint_Unique)    {        Debug.Write("SQLiteError: " + ex.Message);    }    // This works, but is not nice    if (ex.ResultCde == SQLiteErrorCode.Constraint && ex.Message.Contains("UNIQUE"))    {        Debug.Write("SQLiteError: " + ex.Message);    }    throw ex;}有人可以幫我嗎?
查看完整描述

1 回答

?
繁星coding

TA貢獻(xiàn)1797條經(jīng)驗 獲得超4個贊

該功能從 1.0.70.0 版本開始添加:


https://system.data.sqlite.org/index.html/doc/trunk/www/news.wiki


1.0.70.0 - 2011 年 4 月 22 日


通過 SetExtendedResultCodes()、ResultCode() 和 ExtendedResultCode() 添加了對 sqlite3_extended_result_codes()、sqlite3_errcode() 和 sqlite3_extended_errcode() 的支持。通過 SQLiteLogEventHandler() 添加了對 SQLITE_CONFIG_LOG 的支持。


要使用它:


conn.Open();

conn.SetExtendedResultCodes(true);

您可以捕獲異常:


if (ex.ResultCode == SQLiteErrorCode.Constraint_Unique)

{

Debug.Write("SQLiteError: " + ex.Message);

}


查看完整回答
反對 回復(fù) 2021-12-05
  • 1 回答
  • 0 關(guān)注
  • 175 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號