private void btnRecover(object sender, EventArgs e) { try { string sql = string.Format("use master restore database dbcvT from disk='" + textBox1.Text.Trim() + "'"); int i = DbSQL.getbyquery(sql); if (MessageBox.Show("OK", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnBackup(object sender, EventArgs e) { try { string str = Application.StartupPath.ToString(); //获得应用程序的启动路径 str = str.Substring(0, str.LastIndexOf("\\")); //指定获得路径 str = str.Substring(0, str.LastIndexOf("\\")); str += @"\Backup"; string sql = string.Format("backup database dbcvT to disk='" + str + "\\" + textBox1.Text.Trim() + ".bak" + "'"); int i = DbSQL.getbyquery(sql); if (MessageBox.Show("OK", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }