|
-
Apr 12th, 2007, 03:44 PM
#1
Thread Starter
Member
[RESOLVED] SQL Server Express Backup
I am trying to create a Win Form that can create a DB backup with the click of a button. I am trying to allow the user to set the directory to where the ".bak" will go.
Here is what I have:
HTML Code:
if (saveBackupDialog.ShowDialog() == DialogResult.OK)
{
Backup bu = new Backup();
bu.Action = BackupActionType.Database;
bu.Database = "Test"; //database name
//BackupDeviceItem bdi = new BackupDeviceItem(saveBackupDialog.FileName, DeviceType.File);
BackupDeviceItem bdi = new BackupDeviceItem("Test.bak", DeviceType.File);
bu.Devices.Add(bdi);
try
{
Server server = new Server(); //server
bu.SqlBackup(server);
}
catch (Exception x)
{
MessageBox.Show(x.ToString());
Close();
}
}
If you look at the BackupDeviceItem, the commented outline is what I want to do. I want to store the backup to that location. But if I only use a filename it works (the uncommented line) and puts the file in "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup" .
Basically instead of putting the file in C:\\Program Files... I want it to go where teh user selects from the savedialog. Any help is appreciated.
Thanks
-
Apr 17th, 2007, 10:50 AM
#2
Thread Starter
Member
Re: SQL Server Express Backup
Any ideas from anyone, I would really like to be able to do this.
Thanks
-
Apr 17th, 2007, 06:00 PM
#3
Re: SQL Server Express Backup
What actually happens if you try to use a full path? If it won't let you do it then it probably isn't supported.
-
Apr 18th, 2007, 06:22 AM
#4
Re: SQL Server Express Backup
Step through your code and look at what saveBackupDialog.FileName has as its value.
-
Apr 18th, 2007, 07:05 AM
#5
Re: SQL Server Express Backup
-
Apr 18th, 2007, 03:10 PM
#6
Thread Starter
Member
Re: SQL Server Express Backup
Savefilebackup has "C:\Documents and Settings\Mike\My Documents\Backup.bak" which is the correct path to where i want to run it.
Is it possible to run a stored procedure in C#? I really dont understand them so I would like to do what I'm trying now.
thanks
-
Apr 24th, 2007, 06:25 AM
#7
Re: SQL Server Express Backup
 Originally Posted by ekim12987
Is it possible to run a stored procedure in C#? I really dont understand them so I would like to do what I'm trying now.
Have a look here
-
Apr 26th, 2007, 08:05 AM
#8
Thread Starter
Member
Re: SQL Server Express Backup
Thanks, I got that to work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|