无法备份sql server压缩数据库

时间:2013-07-23 06:44:32

标签: sql-server-2008 c#-4.0 sql-server-ce

我正在尝试备份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());
        }

1 个答案:

答案 0 :(得分:2)

使用SQL Server compact,只需使用File.Copy