Dim cn as new sqlconnection
Dim cmd as new sqlcommand
Try
cn.connectionString = "Data Source=localhost;Initial Catalog=master;Trusted_Connection=True;Integrated Security=SSPI;"
cn.open()
cmd.connection = cn
cmd.commandText = "BACKUP DATABASE TestDB TO DISK='C:\yourbackupfilename.bak'"
cmd.ExecuteNonQuery()
Catch ex as Exception
Msgbox(ex.Message)
Finally
cmd.Dispose
cn.Dispose
cn = Nothing
cmd = Nothing
End Try
cmd.CommandText = "RESTORE DATABASE TestDB FROM DISK='C:\yourbackupfilename.bak'"