This is a discussion on Restoring mysqldump file from within c# application within the MySQL forums, part of the Database Server Software category; --> Hello all, I have an unusual request. I am developing a winforms app in C# 2.0 (VS 2005). One ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello all, I have an unusual request. I am developing a winforms app in C# 2.0 (VS 2005). One of the requirements of this application is giving the user the ability to choose a mysqldump file and restore it. Right now I have thrown together the following lines of code to do so: public bool RestoreMySQL(MySQL ms) { string cmd = string.Format(@"-u{0} -p{1} -h{2} {3} < {4};", ms.UserName, ms.PassWord, ms.DbServer, ms.DbName, FilePath); Process proc = new Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = "mysql.exe"; proc.StartInfo.Arguments = cmd; proc.StartInfo.ToString(); bool result = proc.Start(); return result; } (I know it's ugly right now. I am just trying to get it to work in ideal situations then I will handle exceptions etc.) This however does not work. I tried to step this to see what is getting run in the command line but have yet to see a way to do so.The screen flies by way too fast to read. Does anybody either know what I am doing wrong here or, even better, know a way to accomplish this without using a process. Thanks in advance! rbr |
| |||
| "rbr" <ryankbrown@gmail.com> schreef in bericht news:86fe1c68-bd37-499d-b539-0da39c7e93a7@s8g2000prg.googlegroups.com... > Hello all, > > I have an unusual request. I am developing a winforms app in C# 2.0 > (VS 2005). One of the requirements of this application is giving the > user the ability to choose a mysqldump file and restore it. Right now > I have thrown together the following lines of code to do so: > > public bool RestoreMySQL(MySQL ms) > { > string cmd = string.Format(@"-u{0} -p{1} -h{2} {3} < > {4};", ms.UserName, ms.PassWord, ms.DbServer, ms.DbName, FilePath); > > Process proc = new Process(); > > proc.EnableRaisingEvents = false; > proc.StartInfo.FileName = "mysql.exe"; > proc.StartInfo.Arguments = cmd; > proc.StartInfo.ToString(); > > bool result = proc.Start(); > > return result; > } > > (I know it's ugly right now. I am just trying to get it to work in > ideal situations then I will handle exceptions etc.) > > This however does not work. I tried to step this to see what is > getting run in the command line but have yet to see a way to do so.The > screen flies by way too fast to read. > > Does anybody either know what I am doing wrong here or, even better, > know a way to accomplish this without using a process. > > Thanks in advance! > > rbr i think you get a better chance by asking you question in microsoft.public.dotnet.languages.csharp or, try to set a 'MessageBox()' (or the C# equivalent) , displaying your command, in your function or you can try to log this to a textfile |
| ||||
| Did you get any solution for this problem? By the way, what is Process class? br, On Dec 9 2007, 1:33 am, "Luuk" <l...@invalid.lan> wrote: > "rbr" <ryankbr...@gmail.com> schreef in berichtnews:86fe1c68-bd37-499d-b539-0da39c7e93a7@s8g2000prg.googlegroups.com... > > > Hello all, > > > I have an unusual request. I am developing a winforms app in C# 2.0 > > (VS 2005). One of the requirements of this application is giving the > > user the ability to choose a mysqldump file and restore it. Right now > > I have thrown together the following lines of code to do so: > > > public bool RestoreMySQL(MySQL ms) > > { > > string cmd = string.Format(@"-u{0} -p{1} -h{2} {3} < > > {4};", ms.UserName, ms.PassWord, ms.DbServer, ms.DbName, FilePath); > > > Process proc = new Process(); > > > proc.EnableRaisingEvents = false; > > proc.StartInfo.FileName = "mysql.exe"; > > proc.StartInfo.Arguments = cmd; > > proc.StartInfo.ToString(); > > > bool result = proc.Start(); > > > return result; > > } > > > (I know it's ugly right now. I am just trying to get it to work in > > ideal situations then I will handle exceptions etc.) > > > This however does not work. I tried to step this to see what is > > getting run in the command line but have yet to see a way to do so.The > > screen flies by way too fast to read. > > > Does anybody either know what I am doing wrong here or, even better, > > know a way to accomplish this without using a process. > > > Thanks in advance! > > > rbr > > i think you get a better chance by asking you question in > microsoft.public.dotnet.languages.csharp > > or, try to set a 'MessageBox()' (or the C# equivalent) , displaying your > command, in your function > or you can try to log this to a textfile |