Unix Technical Forum

Restoring mysqldump file from within c# application

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:30 AM
rbr
 
Posts: n/a
Default Restoring mysqldump file from within c# application

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:30 AM
Luuk
 
Posts: n/a
Default Re: Restoring mysqldump file from within c# application


"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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:32 AM
Nitesh Shrestha
 
Posts: n/a
Default Re: Restoring mysqldump file from within c# application

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:33 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com