public long InsertQuery(string sql, SQLiteTransaction transaction) { SQLiteCommand sqlCommand; if (transaction != null) { sqlCommand = new SQLiteCommand(sql, this.connection, transaction); } else { sqlCommand = new SQLiteCommand(sql, this.connection); } try { int n_rows = sqlCommand.ExecuteNonQuery(); } catch (Exception ex) { Logger.WriteLine("Exception: {0}", ex); } finally { sqlCommand.Dispose(); } return this.connection.LastInsertRowId; }