Ver código fonte

Fix setting of last autoincrement id for Logs table.

Brett Credo 8 anos atrás
pai
commit
04f9ab63b3
1 arquivos alterados com 10 adições e 14 exclusões
  1. 10 14
      BulkPrinting/BulkPrinting/Utility.cs

+ 10 - 14
BulkPrinting/BulkPrinting/Utility.cs

@@ -1,20 +1,16 @@
1
-using System;
1
+using Newtonsoft.Json;
2
+using System;
2 3
 using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
4
+using System.Data.SQLite;
5
+using System.Globalization;
6 6
 using System.IO;
7
-using System.Net;
7
+using System.Linq;
8 8
 using System.Management;
9
-using Newtonsoft.Json;
10
-using Newtonsoft.Json.Serialization;
11
-using Microsoft.Win32;
9
+using System.Net;
12 10
 using System.Security.Cryptography;
13
-using System.Data.SQLite;
14
-using System.Windows.Forms;
15
-using System.Globalization;
11
+using System.Text;
16 12
 using System.Threading;
17
-using System.Data.Common;
13
+using System.Windows.Forms;
18 14
 
19 15
 namespace BulkPrinting
20 16
 {
@@ -610,9 +606,9 @@ namespace BulkPrinting
610 606
                     using (var command = new SQLiteCommand(conn))
611 607
                     {
612 608
                         command.Transaction = trans;
613
-                        command.Parameters.AddWithValue("@Id", lastSyncedLogId + 1);
609
+                        command.Parameters.AddWithValue("@Id", lastSyncedLogId);
614 610
 
615
-                        command.CommandText = "UPDATE sqlite_sequence SET seq=CASE WHEN seq<@Id THEN @Id ELSE seq END WHERE name='Logs'";
611
+                        command.CommandText = "UPDATE sqlite_sequence SET seq=CASE WHEN IFNULL(seq, 0)<@Id THEN @Id ELSE seq END WHERE name='Logs'";
616 612
                         if (command.ExecuteNonQuery() == 0)
617 613
                         {
618 614
                             command.CommandText = "INSERT INTO sqlite_sequence (name, seq) VALUES ('Logs', @id)";