public bool Add(JObject jo, SQLiteConnectionUser cn, DbTransaction tn = null) { using (DbCommand cmd = cn.CreateCommand("Insert into JournalEntries (EventTime, TravelLogID, CommanderId, EventTypeId , EventType, EventData, EdsmId, Synced) values (@EventTime, @TravelLogID, @CommanderID, @EventTypeId , @EventStrName, @EventData, @EdsmId, @Synced)", tn)) { cmd.AddParameterWithValue("@EventTime", EventTimeUTC); // MUST use UTC connection cmd.AddParameterWithValue("@TravelLogID", TLUId); cmd.AddParameterWithValue("@CommanderID", CommanderId); cmd.AddParameterWithValue("@EventTypeId", EventTypeID); cmd.AddParameterWithValue("@EventStrName", EventTypeStr); cmd.AddParameterWithValue("@EventData", jo.ToString()); cmd.AddParameterWithValue("@EdsmId", EdsmID); cmd.AddParameterWithValue("@Synced", Synced); cn.SQLNonQueryText(cmd); using (DbCommand cmd2 = cn.CreateCommand("Select Max(id) as id from JournalEntries")) { Id = (int)(long)cn.SQLScalar(cmd2); } return(true); } }