예제 #1
0
 public static void ReIndexDB(string fileName)
 {
     using (IDBHelpers dbHelpers = new DBHelpers(fileName))
     {
         string sql = @"SELECT name FROM sqlite_master WHERE type='table' AND name='RecentBattles';";
         using (DataTable tableCheck = dbHelpers.GetDataTable(sql))
         {
             foreach (DataRow row in tableCheck.Rows)
             {
                 dbHelpers.ExecuteNonQuery(String.Format("reindex '{0}'", row["name"]));
             }
         }
     }
 }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string newPath = _dbPath + "_noPassword";

            CreateDatabase.Create(newPath);

            DataTable DT_RB    = new DataTable();
            DataTable DT_RB_RS = new DataTable();

            using (DBHelpers db = new DBHelpers(_dbPath))
            {
                using (var sqliteAdapter = new SQLiteDataAdapter(@"SELECT rbid,[rbcountryid],[rbtankid],[rboriginalbattlecount],[rbbattles],
       [rbkills],
       [rbdamagereceived],[rbdamagedealt],[rbxpreceived],[rbspotted],
       [rbcapturepoints],[rbdefencepoints],[rbsurvived],[rbvictory],
       [rbbattletime],[rbshot],[rbhits],[rbtier],[rbbattlespertier],
       [rbvictorycount],[rbdefeatcount],[rbdrawcount],[rbsurviveyescount],
       [rbsurvivenocount],[rbfraglist],Cast([rbbattletimefriendly] AS TEXT) as rbbattletimefriendly,
       [rbglobalavgtier],[rbglobalwinpercentage],[rbsessionid],
       rbglobalavgdefpoints
FROM   recentbattles", db.GetConnection()))
                {
                    sqliteAdapter.AcceptChangesDuringFill = false;
                    sqliteAdapter.Fill(DT_RB);
                }

                using (var sqliteAdapter = new SQLiteDataAdapter(@"SELECT [rsid],[rskey],Cast([rsdatefrom] AS TEXT) as rsdatefrom,Cast([rsdateto] AS TEXT) as rsdateto, 
       [rsuedatefrom],[rsuedateto] 
FROM   recentbattles_session ", db.GetConnection()))
                {
                    sqliteAdapter.AcceptChangesDuringFill = false;
                    sqliteAdapter.Fill(DT_RB_RS);
                }
            }

            using (DBHelpers db = new DBHelpers(newPath))
            {
                var sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM RecentBattles", db.GetConnection(true));
                var cmdBuilder    = new SQLiteCommandBuilder(sqliteAdapter)
                {
                    SetAllValues = true
                };
                sqliteAdapter.Update(DT_RB);

                sqliteAdapter = new SQLiteDataAdapter("SELECT * FROM RecentBattles_Session", db.GetConnection(true));
                cmdBuilder    = new SQLiteCommandBuilder(sqliteAdapter);
                sqliteAdapter.Update(DT_RB_RS);
            }
        }
예제 #3
0
        public static void Create(string fileName)
        {
            using (IDBHelpers dbHelpers = new DBHelpers(fileName))
            {
                dbHelpers.CreateDatabase(fileName);
                string sql = @"SELECT name FROM sqlite_master WHERE type='table' AND name='RecentBattles';";
                using (DataTable tableCheck = dbHelpers.GetDataTable(sql, true))
                {
                    if (tableCheck.Rows.Count <= 0)
                    {
                        dbHelpers.ExecuteNonQuery(CreateRecentBattlesTable(), true);
                    }
                }

                sql = @"SELECT name FROM sqlite_master WHERE type='table' AND name='RecentBattles_Session';";
                using (DataTable tableCheck = dbHelpers.GetDataTable(sql, true))
                {
                    if (tableCheck.Rows.Count <= 0)
                    {
                        dbHelpers.ExecuteNonQuery(CreateRecentBattlesSessionTable(), true);
                    }
                }
            }
        }