日期:2014-05-18  浏览次数:20773 次

大神给看看这段数据库备份的代码,老提示错误!
private void button1_Click(object sender, EventArgs e)
  {
  string backupname = textBox1.Text; //文件备份名称
  string backup =@"BACKUP DATABASE [MaterialDataBase] TO DISK = N'"+textBox2.Text+"\\"+backupname+@".bak' WITH NOFORMAT, NOINIT, NAME = N'"+backupname+"', SKIP, NOREWIND, NOUNLOAD, STATS = 10 GO";
  MessageBox.Show(backup);
  DataBase.operateSQL(backup); //执行SQL命令
  MessageBox.Show("备份成功!");

  }

  private void button3_Click(object sender, EventArgs e)
  {
  FolderBrowserDialog path = new FolderBrowserDialog();
  if (path.ShowDialog() == DialogResult.OK)
  {
  textBox2.Text = path.SelectedPath;
  }
  }


------解决方案--------------------
设么错,如果是sql语句错误,就好好查查帮助,看看错误提示