本文介绍了当我不能获得数据库备份时如何解决此错误...帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法打开备份设备'I:\ aaa.bak'。操作系统错误32(进程无法访问该文件,因为它正由另一个进程使用。)



这里我的代码



private void button_backup_Click(object sender,EventArgs e)

{

// con是连接字符串

con .Open();

string str =USE TestDB;;

string str1 =BACKUP DATABASE TestDB TO DISK ='E:\ backupfile.Bak'WITH FORMAT,MEDIANAME ='Z_SQLServerBackups',NAME ='Testdb的完全备份';;

SqlCommand cmd1 = new SqlCommand(str,con);

SqlCommand cmd2 = new SqlCommand(str1,con);

cmd1.ExecuteNonQuery();

cmd2.ExecuteNonQuery();

MessageBox.Show(成功 );

con.Close();

}

Cannot open backup device 'I:\aaa.bak'. Operating system error 32(The process cannot access the file because it is being used by another process.).

here my code

private void button_backup_Click(object sender, EventArgs e)
{
//con is the connection string
con.Open();
string str = "USE TestDB;";
string str1="BACKUP DATABASE TestDB TO DISK = 'E:\backupfile.Bak' WITH FORMAT,MEDIANAME = 'Z_SQLServerBackups',NAME = 'Full Backup of Testdb';";
SqlCommand cmd1 = new SqlCommand(str, con);
SqlCommand cmd2 = new SqlCommand(str1, con);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
MessageBox.Show("success");
con.Close();
}

推荐答案


这篇关于当我不能获得数据库备份时如何解决此错误...帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 01:46