private void button2_Click(object sender, System.EventArgs e) { if (textBox_openFile.Text == "") { MessageBox.Show("必须输入争取文件名!", "警告!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } string str_Sql, errorstring = ""; DialogResult result = MessageBox.Show(this, "真的要恢复吗?", "提醒!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { //必须用特殊的到Master数据库的连接,断开所有SchoolManage的向外联系,才能恢复 str_Sql = "restore database " + ConfigurationSettings.AppSettings["Database"] + " from disk='" + textBox_openFile.Text + "' with replace"; errorstring = conn.DBRestore(str_Sql); if (errorstring != "OK") { MessageBox.Show("恢复失败!请检查数据库!" + errorstring, "提醒!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); button1.Enabled = false; return; } MessageBox.Show("恢复成功!" + errorstring, "提醒!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { return; } }