Exemple #1
0
        private void TestConnect_Click(object sender, EventArgs e)
        {
            RefreshInfo();
            SqlConnectionResult SqlConnResult = new SqlConnectionResult();

            SqlConnection = new MySqlConnection(this.ConnectString);
            SqlConnResult = SqlConnection.Connect();
            if (SqlConnResult.isSuccess() == false)
            {
                SqlException theException = SqlConnResult.GetReason();
                MessageBox.Show(theException.Message);
            }
            else
            {
                try
                {
                    SqlConnection.ChangeDatabase(this.Database);
                    MessageBox.Show("警告:该数据库已经存在!");
                }
                catch (SqlException a)
                {
                    a.ToString();
                    MessageBox.Show("通过测试");
                }
                SqlConnection.DisConnect();
            }
        }
Exemple #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         RefreshInfo();
         SqlConnectionResult SqlConnResult = new SqlConnectionResult();
         SqlConnection = new MySqlConnection(this.ConnectString);
         SqlConnResult = SqlConnection.Connect();
         SqlConnection.Exec("drop database [DD]");
         SqlConnection.DisConnect();
         MessageBox.Show("OK");
     }
     catch
     {
         MessageBox.Show("NO");
         SqlConnection.DisConnect();
     }
 }
Exemple #3
0
        private void btnBrandNewDatabase_Click(object sender, EventArgs e)
        {
            string FileName = "Blank.bak";

            try
            {
                RefreshInfo();
                SqlConnectionResult SqlConnResult = new SqlConnectionResult();
                SqlConnection = new MySqlConnection(this.ConnectString);
                SqlConnResult = SqlConnection.Connect();
                CreatDatabaseStructure();
                string queryString = "use [master]\r\n  RESTORE DATABASE DD FROM disk='" + Application.StartupPath + "\\" + FileName + "' with replace";
                SqlConnection.Exec(queryString);
                MessageBox.Show("恢复成功", "提示信息");
                SqlConnection.DisConnect();
            }
            catch
            {
                MessageBox.Show("创建失败");
                SqlConnection.DisConnect();
            }
        }