Taking Backup Problem
Im using Mysql database and visual basic 2010. In my program i put a button named 'Take the back up of the Database' the code is here:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Kontrol As Boolean
Dim Dongu As Integer
Dim Yolumuz As String
Dim SuAnkiYil As String
Dim GecilecekYil As String
Try
SuAnkiYil = Trim(Me.BilgilerDataGridView.Rows(5).Cells(1).Value)
GecilecekYil = Trim(ArsivDataGridView.CurrentCell.Value)
Yolumuz = My.Computer.FileSystem.CurrentDirectory
My.Computer.FileSystem.CreateDirectory(Yolumuz & "/Arsiv/" & SuAnkiYi开发者_高级运维l)
My.Computer.FileSystem.CopyFile(Yolumuz & "/Database1.mdf", Yolumuz & "/Arsiv/" & SuAnkiYil & "/Database1.mdf")
My.Computer.FileSystem.CopyFile(Yolumuz & "/Database1_log.ldf", Yolumuz & "/Arsiv/" & SuAnkiYil & "/Database1_log.ldf")
Catch ex As Exception
MessageBox.Show(ex.Message)
Exit Sub
End Try
when i push the button there becomes an error. "The process cannot access the file because it is being used by another process" is there any way to make program to stop to use the database? i think if we success this, error will fix. Can you please share your opinion?
The problem you have is that the *.mdf file is being used by a database engine - probably your MySQL Server.
There are a few articles out there explaining how to correctly backup a MySQL Database.
http://www.devshed.com/c/a/MySQL/Backing-up-and-restoring-your-MySQL-Database/
http://social.msdn.microsoft.com/Forums/hu-HU/vblanguage/thread/2047bf48-69c4-403a-893c-c36e906a870e
http://www.dotnetspider.com/resources/19537-MySQL-Database-Backup-Restore-from-C-NET.aspx
精彩评论