请教大侠数据库备份问题,哪里出的错……
C# window Form程序private void button1_Click(object sender, EventArgs e)
{
string connectionstring = "server=*******;database=charges;user id=sa;pwd=****";
//建立连接
SqlConnection conn = new SqlConnection(connectionstring);
conn.Open();
string path = @"F:\Test\数据库备份\datarestor\restor.bak";
//备份语句
string backupstr = "backup database charges to disk = '" + path + "'";
SqlCommand cmd = new SqlCommand(backupstr, conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("备份成功!", "提示");
}
catch
{
MessageBox.Show("备份失败!", "提示");
}
finally
{
conn.Close();
}
}
结果总是提示“备份失败!”
在 SQL Server的查询分析器中 输入 backup database charges to disk = 'F:\\Test\\数据库备份\\datarestor\\restor.bak';执行,出息设备无法打开F:\\Test\\数据库备份\\datarestor\\restor.bak 访问遭到拒绝的错误。
问题不知道出在了哪里……请各位给看看……