If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Restore Mysql database query is not working in ASP.NET, C#

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-10, 00:17
santhoshahp santhoshahp is offline
Registered User
 
Join Date: Dec 2010
Posts: 3
Exclamation 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
Reply With Quote
  #2 (permalink)  
Old 12-30-10, 02:03
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 623
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
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 12-30-10, 03:19
santhoshahp santhoshahp is offline
Registered User
 
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();
Reply With Quote
  #4 (permalink)  
Old 12-30-10, 03:37
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 623
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
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #5 (permalink)  
Old 12-30-10, 11:41
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
Reply

Tags
dotnet, mysql

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On