Ejemplo n.º 1
0
        /// <summary>
        /// 判断core.db是否异常
        /// </summary>
        public static void JudeCoreDb()
        {
            string path = Path.Combine(@"C:\Users\Administrator\Desktop\db", "core.db");

            //string path = Path.Combine(RootPath, "db", "core.db");
            if (File.Exists(path))
            {
                SQLiteConnection conn;
                bool             b = SqLiteHelper.TryOpen(path, out conn);
                if (b)
                {
                    string sql = "select * from registrations order by RowID desc limit 1";
                    object obj = SqLiteHelper.ExecuteScalar(conn, sql);
                    if (obj == null)
                    {
                        string s = "delete from registrations";
                        //string s = "delete from registrations where RowID=(select RowID from registrations order by RowID desc limit 1)";
                        SqLiteHelper.ExecuteNonquery(conn, s);
                    }

                    sql = "select * from complete order by RowID desc limit 1";
                    obj = SqLiteHelper.ExecuteScalar(conn, sql);
                    if (obj == null)
                    {
                        string s = "delete from complete";
                        //string s = "delete from registrations where RowID=(select RowID from registrations order by RowID desc limit 1)";
                        SqLiteHelper.ExecuteNonquery(conn, s);
                    }

                    sql = "select * from interfaces order by RowID desc limit 1";
                    obj = SqLiteHelper.ExecuteScalar(conn, sql);
                    if (obj == null)
                    {
                        string s = "delete from interfaces";
                        //string s = "delete from registrations where RowID=(select RowID from registrations order by RowID desc limit 1)";
                        SqLiteHelper.ExecuteNonquery(conn, s);
                    }
                }
                else
                {
                    File.Delete(path);
                }
            }
        }