Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2010
    Posts
    3

    Exclamation Unanswered: Restore Mysql database query is not working in ASP.NET, C#

    Dear Sir/Madam,

    we are using Mysql.exe to restore database by the following query

    string cmd ="-h" + ViewState["host"].ToString() + " " + "-u" + ViewState["user"].ToString() + " " + "-p" + ViewState["password"].ToString() + " " + ViewState["dbName"].ToString() + "<" + " " + Server.MapPath("BackupFiles/") + path;

    The same query is executing in MySql command prompt but we are not able to restore using the above query in VisualStudio .Net, we have tried MysqlImport.exe to do the restore but it was no use. we are newbie to MySql if any help would be appreciated.

    With Regards,

    Santhosha

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    What does the string cmd contain after it has generated? Do you keep track of the return string from the execution of the command to see if there is a specific error message?
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Dec 2010
    Posts
    3

    Exclamation

    Quote Originally Posted by it-iss.com View Post
    What does the string cmd contain after it has generated? Do you keep track of the return string from the execution of the command to see if there is a specific error message?


    Dear Ronan Cashell, Thanks for your reply,here is the complete code please help me.
    String path1 = Server.MapPath("BackupFiles/") + path;
    StreamReader file = new StreamReader(path1); string cmd = string.Format(@"C:\EXE\mysql.exe -u{0} -p{1} -h{2} {3} < {4} ", '"' + ViewState["user"].ToString() + '"', '"' + ViewState["password"].ToString() + '"', '"' + ViewState["host"].ToString() + '"', '"' + ViewState["dbName"].ToString() + '"', '"' + path1 + '"');
    ProcessStartInfo proc = new ProcessStartInfo(@"C:\EXE\mysql.exe", @"/C " + cmd);
    proc.Arguments = cmd;
    proc.UseShellExecute = false;
    string res;
    Process p = new Process();
    p.StartInfo = proc; p.Start();
    res = file.ReadToEnd();
    p.WaitForExit();

  4. #4
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Hi,

    I do not have that much experience using ASP but should you not be using UseShellExecute = true? The redirection is something that is part of the shell and most likely will not be recognized by the application. Again I do not have that much experience so I cannot say for sure.

    The second thing that comes to mind is that the redirection from your backup file, is this a full pathname or relative pathname?

    Finally if a string is returned after executing this might give more information as to the source of the problem.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Try making it work without involving asp first, then make sure asp is doing what you know works.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •