Search code examples
c#sqlitesystem.data.sqliteexecutenonquery

Retrieving error codes from SQLite when using ExecuteNonQuery()


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

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

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


Solution

  • use the Exception.StackTrace or the SQLiteException.ErrorCode

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