Backup database code not working when I add a backup compression option using SMO

278 views Asked by At

Why isn't my backup database code working when I insert a compression option? The single commented line is the culprit, when I remove it the program successfully backs up. But when it isn't commented, Visual Studio has an error that says: An unhandled exception of type System.ExecutionEngineException' occurred in Unknown Module.

Dim bk As New Backup
bk.Action = BackupActionType.Database
bk.BackupSetDescription = "Full backup of " + Main.dbname
bk.BackupSetName = Main.dbname
bk.Database = Main.dbname
//bk.CompressionOption = BackupCompressionOptions.On

Dim bdi As BackupDeviceItem
bdi = New BackupDeviceItem(backupPath + Main.dbname + ".bak", DeviceType.File)

bk.Devices.Add(bdi)
bk.Incremental = False

bk.SqlBackup(srv)

bk.Devices.Remove(bdi)
0

There are 0 answers