German Wear Discount Shop - Click Here Write for Dotnet-friends and earn for your each submission [Dot]Net-Friends
Skip Navigation Links
Home
Latest
Fast Code
Articles
Tutorials
Online Resources
Forums
Login   | Hi, Guest


How to create MSSQL Backup with SQLDMO Object
Written By Omer Kamal On 07/08/2008

create ms sql database Back up using SQL DMO Object

Views: 210
Rating: Please Rate
Login to Rate
omerkamal
Tagged Under: ADO .NET, Data Connection Objects, Database, SQL Server 2005

Explanation:

try
{
SQLDMO._SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect("server","username","password");

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

MessageBox.Show("Database backed up successfully.", "Backup Successfull");

this.Cursor = Cursors.Default;
}
catch(Exception err)
{
this.Cursor = Cursors.Default;
MessageBox.Show(err.Message,"Error");
}
Delicious Digg reddit reddit Technorati
About the Author:

@@ Omer Kamal is a Software Developer at Elanize KG Germany. He MSc. Mathematics from Islamia University Bahawalpur, Pakistan and Certified Developer from National Institute of Electronics Islamabad, Pakistan. He is Founder of FriendsPoint.de and Dotnet-Friends.com. He is currently Involved with Microsoft Office SharePoint 2007, Microsoft Dynamics CRM, BI Portal Solutions (Microsoft Dynamics Customization) and Web Security Solutions.
Check Omer Kamal Profile

Related Useful Links:
Visitors/Readers Comments
(for questions please use The Forum)



"Be the First to Comment!"


Add your Comments

Name:  
Message:
Note: For faster response please use Forums >> for your questions instead of the comments area! (Admin)