Exemplo n.º 1
0
 void Load(LParam _L)
 {
     foreach (Param p in _L)
     {
         if (p.IsZero())
         {
             break;
         }
         string SQL;
         if (p.val == null || p.val.Length == 0)
         {
             SQL = string.Format("insert into LST (path) values('{0}')", p.path);
         }
         else
         {
             SQL = string.Format("insert into LST values('{0}','{1}')", p.path, p.val);
         }
         using (SQLiteCommand cmd = new SQLiteCommand(SQL, connection))
         {
             if (cmd.ExecuteNonQuery() != 1)
             {
                 FN.fatal("Ошибка:" + SQL);
             }
         }
     }
 }
Exemplo n.º 2
0
        public SerialTreeFile(LParam _L)
        {
            connection = new SQLiteConnection("Data Source=:memory:");
            connection.Open();
            string SQL = "CREATE TABLE LST (path TEXT PRIMARY KEY NOT NULL, val  TEXT)";

            using (SQLiteCommand p = new SQLiteCommand(SQL, connection)) p.ExecuteNonQuery();
            Load(_L);
//            new SerialTreeSQL("Uran").Save(_L);
        }
Exemplo n.º 3
0
 internal void Save(LParam _L)
 {
     CDBS.BeginTransaction();
     try
     {
         new ExecSQLX(string.Format("delete from {0}", s_table)).Exec();
         foreach (Param p in _L)
         {
             ExecSQLX E = new ExecSQLX(string.Format("insert into {0} values('{1}','{2}')", s_table, p.path.Replace('[', '{').Replace(']', '}'), p.val));
             if (E.Exec() != 1)
             {
                 CDBS.RollBack();
                 throw new Exception("Не смогли записать настройки в базу");
             }
         }
     }
     catch
     {
         CDBS.RollBack();
         throw new Exception("Не смогли записать настройки в базу");
     }
     CDBS.Commit();
 }