From c6bf6b077d29fb1600fed47fa3a7d449911c3e17 Mon Sep 17 00:00:00 2001 From: Frank Fesevur Date: Fri, 15 May 2015 15:51:37 +0200 Subject: [PATCH] Fix bug when inserting new records. Identify column on name instead of on number --- Library.cpp | 4 ++-- Snippets.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Library.cpp b/Library.cpp index d4b776b..a77f75a 100755 --- a/Library.cpp +++ b/Library.cpp @@ -101,9 +101,9 @@ bool Library::SaveToDB(bool autoOpen) if (_LibraryID == 0) { // Determine the last used LibraryID - SqliteStatement stmt2(g_db, "SELECT MAX(LibraryID) FROM Library"); + SqliteStatement stmt2(g_db, "SELECT MAX(LibraryID) AS MaxID FROM Library"); stmt2.GetNextRecord(); - _LibraryID = stmt2.GetIntColumn(1) + 1; + _LibraryID = stmt2.GetIntColumn("MaxID") + 1; stmt2.Finalize(); // Prepare the statement diff --git a/Snippets.cpp b/Snippets.cpp index a883ba8..a87e9a1 100755 --- a/Snippets.cpp +++ b/Snippets.cpp @@ -221,9 +221,9 @@ bool Snippet::SaveToDB(bool autoOpen) adding = true; // Determine the last used SnippetID - SqliteStatement stmt2(g_db, "SELECT MAX(SnippetID) FROM Snippets"); + SqliteStatement stmt2(g_db, "SELECT MAX(SnippetID) AS MaxID FROM Snippets"); stmt2.GetNextRecord(); - _SnippetID = stmt2.GetIntColumn(1) + 1; + _SnippetID = stmt2.GetIntColumn("MaxID") + 1; stmt2.Finalize(); // Prepare the statement