how to take database backup

  • Thread starter Thread starter Abhijit Taur
  • Start date Start date
A

Abhijit Taur

hi
i am using vb.net2005
i want to take daily backup from application
and attach that daily backup if any data loss
 
Abhijit Taur said:
hi
i am using vb.net2005
i want to take daily backup from application
and attach that daily backup if any data loss

You need to use Microsoft.SqlServer.Management objects

using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
....
using (SqlConnection conn = new SqlConnection(connString))
{
ServerConnection serverConnection = new ServerConnection(conn);
Server server = new Server(serverConnection);
Backup backup = new Backup();
backup.SqlBackup(server);
}

Translate to vb.net as necessary (PS you did as a C# group :P )

You will most likely have to set several properties on the Backup object
before calling SqlBackup, as well as subscribe to events.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top