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

مشاهدة النسخة كاملة : restoring database using c#



C# Programming
03-18-2012, 11:00 PM
sir i providing code by which i am implementing restore database ....but sir code is running successfully but no restoration is done at the end ......
help plz thanx in advance http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif




public void Restore() { try { //Read file from C:\ 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.exe"; 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 = Process.Start(psi); process.StandardInput.WriteLine(input); process.StandardInput.Close(); process.WaitForExit(); process.Close(); MessageBox.Show("database is restored"); } catch (IOException ex) { MessageBox.Show("Error , unable to Restore!"); } } private void bstart_Click(object sender, EventArgs e) { Restore(); }