我正在尝试备份 sql server compact 数据库,我使用了此代码,但它不起作用。
var srv = new Server(@".\SQLEXPRESS");
SaveFileDialog SD = new SaveFileDialog();
SD.ShowDialog();
Backup BkpDBase = new Backup();
this.Cursor = this.Cursor = Cursors.WaitCursor;
//this.dataGridView1.DataSource = string.Empty;
try
{
string fileName = SD.FileName;
BkpDBase.Action = BackupActionType.Database;
BkpDBase.Database = "TapeDatabase.sdf";
BackupDeviceItem bkpDevice = new BackupDeviceItem(fileName, DeviceType.File);
BkpDBase.Devices.Add(bkpDevice);
BkpDBase.SqlBackup(srv);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}