Esempio n. 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == string.Empty)
     {
         MessageBox.Show(@"新密码不能为空!");
         return;
     }
     try
     {
         Init(out var err);
         if (err != string.Empty)
         {
             MessageBox.Show(err);
         }
         else
         {
             if (ChangePwd(textBox1.Text))
             {
                 MessageBox.Show(@"密码修改成功!");
             }
             YxLog.Info($@"修改数据库密码为:{textBox1.Text}");
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         YxLog.Error(exception);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 测试数据库连接情况
 /// </summary>
 private static bool Test()
 {
     try
     {
         Query("select name from sqlite_master");
         return(true);
     }
     catch (Exception ex)
     {
         YxLog.Error(ex);
         throw new Exception("连接数据库异常:" + ex.Message);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 修改数据库密码
 /// </summary>
 /// <param name="pwd">不给此参数是删除密码</param>
 /// <returns></returns>
 public static bool ChangePwd(string pwd = "")
 {
     using (var conn = GetSqLiteConnection())
     {
         try
         {
             conn.Open();
             conn.ChangePassword(pwd);
         }
         catch (Exception ex)
         {
             YxLog.Error(ex);
             throw new Exception("连接数据库异常:" + ex.Message);
         }
     }
     return(true);
 }
Esempio n. 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Init(out var err); if (err != string.Empty)
         {
             MessageBox.Show(err);
         }
         else
         {
             if (!ChangePwd())
             {
                 return;
             }
             MessageBox.Show(@"密码删除成功!");
             YxLog.Info(@"数据库密码删除成功");
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         YxLog.Error(exception);
     }
 }