471,348 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Create SQL Backup with SQLDMO.dll

Hi all,

I want to create a backup of a database using SQLDMO in C#. But I keep
on getting a exception. If anyone can help me by providing code for
this, it would be appreciated. Thanks in advance...

this.Cursor = Cursors.WaitCursor;
SQLDMO._SQLServer srv = new SQLDMO.SQLServerClass();

SQLDMO.Backup bak = new SQLDMO.BackupClass();
bak.Devices = bak.Files;
string path = txtPath.Text; //Path where the backup should be
path = "[" + path + "]";
bak.Files = path;
bak.Database = "DatabaseName";

MessageBox.Show("Database backed up successfully.", "Backup
this.Cursor = Cursors.Default;
catch(Exception err)
this.Cursor = Cursors.Default;


[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open backup
device 'C:\test\BackupName.BAK'. Device error or device off-line. See
SQL Server error log for more details.
[Microsoft][ODBC SQL Server Driver][SQL Server]BACKUP DATABASE is
terminating abnormally.

Dec 8 '05 #1
1 5600
Sorry, no need to reply on this post, it was my own stupidity that
caused that exception. The code works perfectly...


Dec 8 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by acko bogicevic | last post: by
1 post views Thread by john_20_28_2000 | last post: by
reply views Thread by Chandra | last post: by
2 posts views Thread by Mohammed Abdel-Razzak | last post: by
3 posts views Thread by T. | last post: by
1 post views Thread by | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.