我正在尝试备份sql server压缩数据库,我使用了这段代码,但它无法正常工作。
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());
}
答案 0 :(得分:2)
使用SQL Server compact,只需使用File.Copy