string sql = "BACKUP DATABASE" + comboBox1.SelectedText.ToString() +
" to disk = '" + textBox1.Text.ToString() + "'\'" +
comboBox1.SelectedText+"'.bak";
答案 0 :(得分:0)
try
{
if (!string.IsNullOrWhiteSpace(textBox1.Text))
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Anjum-Dar\Documents\Visual Studio 2012\managerecord\managerecord\recordemanage.mdf;Integrated Security=True");
con.Open();
string sql = "BACKUP DATABASE" + comboBox1.SelectedText.ToString() + " to disk = '" + textBox1.Text.ToString() + "'\'" + comboBox1.SelectedText + "'.bak";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Successfully ");
}
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}