I'm logged in as an admin on my PC, but this shows up
here's my code:
string file = "C:\\Users\\owner\\Documents\\backup.sql";
using (MySqlConnection conn = new MySqlConnection(constring))
{
using (MySqlCommand cmd = new MySqlCommand())
{
using (MySqlBackup mb = new MySqlBackup(cmd))
{
try
{
cmd.Connection = conn;
conn.Open();
mb.ExportToFile(file);
conn.Close();
}catch(Exception ex){
MessageBox.Show(ex.Message);
}
}
}
}
PS: I already have a connection string at the very top of my code.
There is a possibility, that you are getting the error because the file doesn't exist. I could be wrong, but I looked into the source and it doesn't check whether the file already exists.
hey ? are you using mysqlbackup.dll as reference ? if yes maybe this can help .. just go to the folder you want to be the storage of your saved files
Private Sub BackupDatabaseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackupDatabaseToolStripMenuItem.Click
'using mysqlbackup.dll as reference
Dim cmd As MySqlCommand = New MySqlCommand
cmd.Connection = connect()
Dim filepth As String = "C:\Users\IT\Documents\DB_Backup.sql"
Dim mb As MySqlBackup = New MySqlBackup(cmd)
mb.ExportToFile(filepth)
MsgBox("Database Backup Successfully !", MsgBoxStyle.Information, "Project")
disconnect()
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.