SqlBackup from my client app

Posted by Robbert Dam on Stack Overflow See other posts from Stack Overflow or by Robbert Dam
Published on 2010-03-24T09:18:51Z Indexed on 2010/03/26 8:13 UTC
Read the original article Hit count: 405

Filed under:
|
|

I have an client app that runs on several machines, and connects to a single SQL database. On the client app, the user has the possiblity to use a local SQL (CE) database or connect to a remote SQL database. There is also a box where a backup location can be set.

For the backup of the remote SQL database I use the following code:

var bdi = new BackupDeviceItem(backupFile, DeviceType.File); var backup = new Backup { Database = "AppDb", Initialize = true };

backup.Devices.Add(bdi);

var server = new Server(connection); backup.SqlBackup(server);

When developing my application, I wasn't aware that the given backupFile is written on the machine where the SQL server runs! And not on the client machine.

What I want is "dump" all the data from my database to a local file.

(Why? Because users may enter a network location in the "backup location" box, and backing up SQL immediately to a network location fails. So need to write local first and then copy to the network in that case.)

I there an alternative to the method above?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about sql