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

مشاهدة النسخة كاملة : MySQL restore database through c#



C# Programming
06-30-2009, 04:11 PM
Hi
I have used multiple ways to restore mysql schema through c# but it doesnot seems to work as the database doesnot restores properly,
please tell me what to do, my code for restore is as under
string filename = backupName;
StreamWriter file = new StreamWriter(filename);
file.WriteLine("@ECHO off");
file.WriteLine("cls");
file.WriteLine("set DBchoice=%1%");
file.WriteLine("set User=%2%");
file.WriteLine("set Password=%3%");
file.WriteLine("set pathchoice=%4%");
file.WriteLine("");
file.WriteLine("@REM Remove double quotes from the path");
file.WriteLine("@REM SET pathchoice=%pathchoice:\"=%");
file.WriteLine("@REM SET pathchoice=%pathchoice:\"=%");
file.WriteLine("");
file.WriteLine("mysql -u " + Id + " --password=" + pwd + " " + dbName + " testdb.sql";
proc.UseShellExecute = false;
Process p = Process.Start(proc);
string res;

res = file.ReadToEnd();
p.StandardInput.Write(res);

// res = p.StandardInput.Write .StandardOutput.ReadToEnd();
//file.WriteLine(res);
p.WaitForExit();
file.Close();
return "Data restored successfully";
please give me any suggestions

regards,
Mariam