المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : problem in restoring mysql database



C# Programming
04-15-2012, 04:03 PM
sir when i am running this code then process is throwing an exception ....and value of exit code becoming 1 ....i dont know why it is happening so ..plz help me ..
public void Restore() { try { string path; path = filetext.Text; StreamReader file = new StreamReader(path); string input = file.ReadToEnd(); file.Close(); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqlimport"; // psi.FileName = "mysql"; psi.RedirectStandardInput = true; psi.RedirectStandardOutput = false; psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}",userid, paswd, server, comboBox1.Text); psi.UseShellExecute = false; Process process = new Process(); //process.StartInfo = psi; //process= Process.Start("IExplore.exe"); process = Process.Start(psi); //process.WaitForInputIdle(); //process.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal; process.StandardInput.WriteLine(input); process.StandardInput.Close(); process.WaitForExit(); process.Close(); MessageBox.Show("database is restored"); } catch (IOException ex) { if (System.Diagnostics.Debugger.IsAttached) { Console.WriteLine(ex.ToString()); } else MessageBox.Show("Error , unable to Restore!"); } }