You can use SMO
Add these references:
'//***** Add these references**********
'
'//Microsoft.SqlServer.SmoExtended
'
'//Microsoft.SqlServer.ConnectionInfo
Add these Imports:
Imports System.Data.SqlClient
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common
Then code something like this:
Private Sub Backup
Dim srv As Server
Dim conn As ServerConnection
Dim sqlSErverInstance As String = "YourServerInstanceName"
Dim fileName As String = "MyBackup.bak"
Dim databaseName As String = "MyDatabase"
conn = New ServerConnection(sqlSErverInstance, "Username", "Password")
srv = New Server(conn)
Dim bkp As New Backup()
Try
bkp.Action = BackupActionType.Database
bkp.Database = databaseName
bkp.Devices.AddDevice(fileName, DeviceType.File)
bkp.Incremental = False
bkp.PercentCompleteNotification = 10
AddHandler bkp.PercentComplete, AddressOf ProgressEventHandler
bkp.SqlBackup(srv)
MessageBox.Show("Database Backed Up To: " & fileName, "Backup")
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
Me.ProgressBar1.Value = 0
End Try
End Sub
Public Sub ProgressEventHandler(sender As Object, e As PercentCompleteEventArgs)
Me.ProgressBar1.Value = e.Percent
End Sub