5
我知道如何使用C#和SMO到SQL Server上創建文件備份:使用C#&SMO,如何將備份設備添加到SQL Server?
public void BackupDatabase(Microsoft.SqlServer.Management.Smo.Server server,
string databaseName, string backupFilename,
string backupName, string backupDescription) {
Backup backup = new Backup();
backup.Devices.AddDevice(backupFilename, DeviceType.File);
backup.Database = databaseName;
backup.Action = BackupActionType.Database;
backup.BackupSetDescription = backupDescription;
backup.BackupSetName = backupName;
backup.Incremental = false;
backup.LogTruncation = BackupTruncateLogType.Truncate;
backup.Initialize = true; // supposed to overwrite
backup.SqlBackup(server);
}
我不知道什麼(找不到)是如何將文件BackupDevice添加到SQL服務器。
@瑞摩斯-rusanu:謝謝了!我錯過了.Create()。 – 2010-03-18 20:30:37