本文介绍了如何使用C#编写在Windows应用程序中备份和恢复的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了应用程序Windows应用程序c#,因为我需要取回数据库,但我写的是显示流动错误

服务器Shiv-PC备份失败



我尝试过:



string backUpdriveName = cmbDriveList.Text;

string DatabaseName = cmbDriveNameList.Text;

File.Delete(backUpdriveName +\\\\ backup.bak);

备份bkpDatabase = new Backup ();

bkpDatabase.Action = BackupActionType.Database;

bkpDatabase.Database = DataBaseName;

BackupDeviceItem bkpDevice = new BackupDeviceItem(backUpdriveName + Backup.bak,DeviceType.File);

bkpDatabase.Devices.Add(bkpDevice);

Server srvr;

srvr = new Server ();

bkpDatabase.SqlBackup(srvr); //此行显示错误服务器Shiv-PC的备份失败

I have develop application windows application c#, for that i need to take back Up of database, But my written is showing flowing error
"Backup failed for Server Shiv-PC"

What I have tried:

string backUpdriveName = cmbDriveList.Text;
string DatabaseName=cmbDriveNameList.Text;
File.Delete(backUpdriveName + "\\backup.bak");
Backup bkpDatabase = new Backup();
bkpDatabase.Action = BackupActionType.Database;
bkpDatabase.Database = DataBaseName;
BackupDeviceItem bkpDevice = new BackupDeviceItem(backUpdriveName + "Backup.bak", DeviceType.File);
bkpDatabase.Devices.Add(bkpDevice);
Server srvr;
srvr = new Server();
bkpDatabase.SqlBackup(srvr); // This Line is Showing error "Backup failed for Server Shiv-PC"

推荐答案


BackupDeviceItem bkpDevice = new BackupDeviceItem(backUpdriveName + "Backup.bak", DeviceType.File);



to


to

BackupDeviceItem bkpDevice = new BackupDeviceItem(backUpdriveName + "\\Backup.bak", DeviceType.File);





类似的问题在这里

谢谢



Similar question asked here SQL Server backup failed for server xxxx
Thanks


这篇关于如何使用C#编写在Windows应用程序中备份和恢复的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 06:31