vb.net,恢复mysql数据库无法在windows xp中运行

时间:2013-04-24 01:03:30

标签: mysql database vb.net restore

我有一个使用vb.net恢复mysql数据库的代码。它完全适用于Windows 7但是当我在windows xp中尝试它时它不起作用。希望你们都能帮助我。这是我的代码..

   Function RestoreDb()
    With dlg_openfile 'Executes a series of statements making repeated reference to a single object or structure.
        .Title = "Please Select a Image" 'title
        .InitialDirectory = "C:\" 'browse start directory
        .Filter = "All files (*.*)|*.*|All files (*.*)|*.*" 'only possible to select this extensions
        .FilterIndex = 0 'index number filter
        .FileName = "" 'empty
        Dim answ = .ShowDialog
        If answ = DialogResult.OK Then 'if answer not cancel, etc..
            Dim myProcess As New Process()
            myProcess.StartInfo.FileName = "cmd.exe"
            myProcess.StartInfo.UseShellExecute = False
            myProcess.StartInfo.WorkingDirectory = "C:\wamp\bin\mysql\mysql5.5.24\bin\"
            myProcess.StartInfo.RedirectStandardInput = True
            myProcess.StartInfo.RedirectStandardOutput = True
            myProcess.Start()
            Dim myStreamWriter As StreamWriter = myProcess.StandardInput
            Dim mystreamreader As StreamReader = myProcess.StandardOutput
            myStreamWriter.WriteLine(String.Format("mysql -u IS_DB -p2240624 db_innovaserver < {0}", .FileName))
            myStreamWriter.Close()
            myProcess.WaitForExit()
            myProcess.Close()
        End If
    End With

End Function

1 个答案:

答案 0 :(得分:0)

试试这个

 Function RestoreDb()
With dlg_openfile 'Executes a series of statements making repeated reference to a single object or structure.
    .Title = "Please Select a Image" 'title
    .InitialDirectory = "C:\" 'browse start directory
    .Filter = "All files (*.*)|*.*|All files (*.*)|*.*" 'only possible to select this extensions
    .FilterIndex = 0 'index number filter
    .FileName = "" 'empty
    Dim answ = .ShowDialog
    If answ = DialogResult.OK Then 'if answer not cancel, etc..
        Dim myProcess As New Process()
        myProcess.StartInfo.FileName = "cmd.exe"
        myProcess.StartInfo.UseShellExecute = False

        myProcess.StartInfo.RedirectStandardInput = True
        myProcess.StartInfo.RedirectStandardOutput = True
        myProcess.Start()
        Dim myStreamWriter As StreamWriter = myProcess.StandardInput
        Dim mystreamreader As StreamReader = myProcess.StandardOutput
        myStreamWriter.WriteLine(String.Format("C:\wamp\bin\mysql\mysql5.5.24\bin\mysql.exe -u IS_DB -p2240624 db_innovaserver < {0}", "dbFile.sql"))
        myStreamWriter.Close()
        myProcess.WaitForExit()
        myProcess.Close()
    End If
End With

结束功能