当我点击按钮' RESTORE DATABASE'时,我需要恢复我使用的基于服务的数据库的MySQL数据库。我正在使用VB.Net 2010.我已经针对任何解决方案进行了研究,但我无法想出如何使其工作。你有什么想法可能有帮助吗?我目前正在做如何备份数据库,所以任何帮助都会非常感激。
Private Sub cmdrestore_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrestore.Click
Dim s As System.IO.StreamWriter
Try
Dim portfolioPath As String = My.Application.Info.DirectoryPath
FileCopy(portfolioPath & "\Backup\Database1.mdf", "C:\Payroll System\Database1.Mdf")
MsgBox("Restore completed successfully", vbInformation, "DBBES-B Payroll System")
Catch ex As Exception
Dim MessageString As String = "Report this error to the system administrator: " & ControlChars.NewLine & ex.Message
Dim TitleString As String = "Employee Master Details Data Load Failed"
MessageBox.Show(MessageString, TitleString, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
答案 0 :(得分:1)
首先,您需要创建一个成功还原数据库的批处理文件。搜索Google时有很多示例(MySQL database restore script)。
然后,您的按钮将使用Process类调用批处理文件,就像找到的HERE示例一样。您将使用.bat当然不是.exe。