Esempio n. 1
0
 /// <summary>
 /// 执行压缩数据库
 /// </summary>
 /// <returns>压缩数据库</returns>
 public void ExecuteZip()
 {
     using (SQLiteConnection connection = new SQLiteConnection(ConnectionString, true))
     {
         using (SQLiteCommand cmd = new SQLiteCommand("VACUUM", connection))
         {
             try
             {
                 connection.Open();
                 cmd.ExecuteNonQuery();
             }
             catch (System.Data.SQLite.SQLiteException E)
             {
                 connection.Close();
                 Comm_Method.ShowErrorMessage(E.Message);
                 //throw new Exception(E.Message);
             }
         }
     }
 }
Esempio n. 2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            foreach (Control item in this.Controls)
            {
                if (item is TextBox)
                {
                    if (string.IsNullOrWhiteSpace(((TextBox)item).Text))
                    {
                        Comm_Method.ShowErrorMessage("不能为空!");
                    }
                }
            }

            if (this.ID == 0)
            {
                string sqlStr = "INSERT INTO [Ywj]([Name],[Path],[PathMove])VALUES("
                                + "'" + this.textBoxName.Text.Trim() + "',"
                                + "'" + this.textBoxYwjPath.Text.Trim() + "',"
                                + "'" + this.textBoxYwjPathMove.Text.Trim() + "');";
                if (SQLiteList.Ybf.ExecuteNonQuery(sqlStr) > 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
            else if (this.ID > 0)
            {
                string sqlStr = "UPDATE [Ywj] SET "
                                + "[Name]='" + this.textBoxName.Text.Trim() + "',"
                                + "[Path]='" + this.textBoxYwjPath.Text.Trim() + "',"
                                + "[PathMove]='" + this.textBoxYwjPathMove.Text.Trim() + "'"
                                + " WHERE ID=" + this.ID;
                if (SQLiteList.Ybf.ExecuteNonQuery(sqlStr) > 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
        }