Skip to content

Commit

Permalink
Fix bug when inserting new records.
Browse files Browse the repository at this point in the history
Identify column on name instead of on number
  • Loading branch information
ffes committed May 15, 2015
1 parent 6bf51fd commit c6bf6b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Snippets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c6bf6b0

Please sign in to comment.