-1

我在我的电脑上以管理员身份登录,但这显示

这是我的代码:

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:我的代码顶部已经有一个连接字符串。

4

2 回答 2

0

由于文件不存在,您可能会收到错误消息。我可能是错的,但我查看了源代码并没有检查文件是否已经存在。

于 2016-02-19T20:59:57.927 回答
-3

嘿 ?您是否使用 mysqlbackup.dll 作为参考?如果是的话,也许这会有所帮助..只需转到您想要存储已保存文件的文件夹

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
于 2021-01-14T03:50:11.503 回答