在界面上使用button按钮触发
备份过程如下:
Private Sub Button_backup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_backup.Click
'执行备份过程
Try
‘备份数据库
Me.backupDb()
MsgBox("数据成功备出!", MsgBoxStyle.OKOnly)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OKOnly)
End Try
End Sub
’备份方法其中backupDir为应用程序中制定备份路径的全局变量,在应用程序启动的时候从配置文件里面读出来的值
Private Sub backupDb()
Dim mysqlcomm As SqlClient.SqlCommand
Dim strsql As String
Dim strbak As String
Try
'判断备份路径参数里面是否制定路径
If backupDir <> Nothing Then
'判断路径是否存在
If Not System.IO.Directory.Exists(backupDir) Then
'创建路径
System.IO.Directory.Cre