|
Ok, I have found the problem and also resolution.
Consider following points in resolution.
1. Don't provide password when you are building arguments. You need to provide it later on
when you prompted for it.
2. you need to give filename as cmd.exe instead of mysql, because it will come under the
arguments.
For example, build your arguments as follows
string cmd = string.Format(@"C:\wamp\bin\mysql\mysql5.1.36\bin\mysql.exe -u {0} -p -h {1} {2} < {3}", "root", "localhost", "test123", @"C:\wamp\bin\mysql\mysql5.1.36\bin\wp.sql");
ProcessStartInfo proc = new ProcessStartInfo("cmd", @"/C " + cmd);
proc.UseShellExecute = false;
Process p = new Process();
p.StartInfo = proc;
p.Start();
p.WaitForExit();
See it I have not provided password. It should ask me for the password when I execute the process.
And that's it. It is now importing mysqldump file successfully.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
i changed as per instruction but again it is running but not saving to database and also not asking password and also we are not using wamp, we are using mysql 5.0. Please help.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace dump
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
restore_data("temple1");
}
catch (Exception ex)
{
Application.Exit();
}
}
public void restore_data(string database)
{
StreamReader file = new StreamReader("E:\\BackupMysql1\\temple.sql");
string cmd = string.Format(@"C:\Program Files\MySQL\MySQL Server 5.0\bin\cmd.exe -u{0} -p -h{1} (2) < {3} ", "root", "localhost", '"' + database + '"', "E:\\BackupMysql1\\temple.sql");
ProcessStartInfo proc = new ProcessStartInfo("cmd", @"/C " + cmd);
//proc.RedirectStandardInput = true;
//proc.RedirectStandardOutput = false;
proc.Arguments = cmd;
proc.UseShellExecute = false;
//Process p = Process.Start(proc);
string res;
//res = file.ReadToEnd();
//p.WaitForExit();
//file.Close();
Process p = new Process();
p.StartInfo = proc;
p.Start();
res = file.ReadToEnd();
p.WaitForExit();
}
}
}
|
|
|
|
|
i changed as per instruction but again it is running but not saving to database and also not asking password and also we are not using wamp, we are using mysql 5.0. Please help.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace dump
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
restore_data("temple1");
}
catch (Exception ex)
{
Application.Exit();
}
}
public void restore_data(string database)
{
StreamReader file = new StreamReader("E:\\BackupMysql1\\temple.sql");
string cmd = string.Format(@"C:\Program Files\MySQL\MySQL Server 5.0\bin\cmd.exe -u{0} -p -h{1} (2) < {3} ", "root", "localhost", '"' + database + '"', "E:\\BackupMysql1\\temple.sql");
ProcessStartInfo proc = new ProcessStartInfo("cmd", @"/C " + cmd);
//proc.RedirectStandardInput = true;
//proc.RedirectStandardOutput = false;
proc.Arguments = cmd;
proc.UseShellExecute = false;
//Process p = Process.Start(proc);
string res;
//res = file.ReadToEnd();
//p.WaitForExit();
//file.Close();
Process p = new Process();
p.StartInfo = proc;
p.Start();
res = file.ReadToEnd();
p.WaitForExit();
}
}
}
|
|
|
|
|
hi sr159,
You are not reading my answer. Again running wrong command.
Just read my answer carefully. I have supplied mysql instead of cmd command.
Instead of below line...
string cmd = string.Format(@"C:\Program Files\MySQL\MySQL Server 5.0\bin\cmd.exe -u{0} -p -h{1} (2) < {3} ", "root", "localhost", '"' + database + '"', "E:\\BackupMysql1\\temple.sql");
Just use the line...
string cmd = string.Format(@"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe -u{0} -p -h{1} (2) < {3} ", "root", "localhost", '"' + database + '"', "E:\\BackupMysql1\\temple.sql");
And now execute the command. And try to edit your question not re-post or posting totally new question as reply by changing the message type.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
i changed cmd.exe to mysql.exe then also it is executing but not saving dump file to database using C#.
|
|
|
|
|
after running the processor which is taking the path is D:\the application folder name and not asking password.
|
|
|
|
|
problem solved now it is working thank you for all who replied to me
|
|
|
|
|
Thanks in advance.
how to convert a windows long path name to short pathname in VB.Net.
|
|
|
|
|
Find following code useful for the same.
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
[MarshalAs(UnmanagedType.LPTStr)]
string path,
[MarshalAs(UnmanagedType.LPTStr)]
StringBuilder shortPath,
int shortPathLength
);
public static void Main()
{
StringBuilder shortPath = new StringBuilder(255);
GetShortPathName(@"D:\My Temp\ResourseProvider\sql.txt", shortPath, shortPath.Capacity);
Console.WriteLine(shortPath.ToString());
}
The code is in C#, however you can do the same with syntactical changes in vb.net.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I dunno who downvoted you, but I ran your code and it returned a correct answer. I got
E:\MYTEMP~1\RESOUR~1\sql.txt
However, it will fail if the path does not exist. Try the API on an existing path, and it will work.
I are Troll
|
|
|
|
|
thanks for the reply. Can you please give the code in vb.net syntax.
|
|
|
|
|
Imports System
Imports System.Runtime.InteropServices
Imports System.Text
Namespace Test
Class Program
<DllImport("kernel32.dll", CharSet := CharSet.Auto)> _
Public Shared Function GetShortPathName( _
<MarshalAs(UnmanagedType.LPTStr)> path As String, _
<MarshalAs(UnmanagedType.LPTStr)> shortPath As StringBuilder, _
shortPathLength As Integer _
) As Integer
End Function
Public Shared Sub Main()
Dim shortPath As New StringBuilder(255)
GetShortPathName( _
"E:\My Temp\ResourseProvider\sql.txt", _
shortPath, _
shortPath.Capacity)
Console.WriteLine(shortPath.ToString())
Console.ReadKey()
End Sub
End Class
End Namespace
There you are
I are Troll
|
|
|
|
|
hi experts,
my windows forms application, is unable to be executed in a PC where dotnet is not installed.
the reason i expect would be, because, iam using a dll in my application.
though i make a release version, there is no use.
please let me know if any details are required from my side.
any suggestions to get through my problem would be appreiciable.
thanks in advance,
chandu.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Are you sure that all dll libraries that you reference are installed on the target machine? Also you need to be sure that the machine supports the version of .NET that you have compiled against.
It's time for a new signature.
|
|
|
|
|
Running a Windows .NET application requires the presence of Windows and .NET
If you use an installer, make .NET one of the prerequisites there.
|
|
|
|
|
|
I'm sorry, but I can't see what you are after here. Was there a code block in there that didn't get rendered?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
THS is up .5% today, but I don't think that is enough of a progress bar to provide a stock tip to such a wide audience.
|
|
|
|
|
bisharbn wrote: Please see ths
What?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Dear All
I'm .Net developer. In my project, When I compile a DLL in Vista PC and run it from the same PC It didn't response. When I disable DEP it responded but took too much time. But the same DLL which is complied in Xp machine response very quickly in Vista PC.( Complied in Xp and run in Vista)
What might be the reason for this greater performance issue?
Thank you,
RSumanan
|
|
|
|
|
Please do not repost. You have already posted question here[^]
Post your question only once.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Experts,
I have created one windows application and deployed it in some 500 machines in my company. The problem is, the applicaiton is updated weekely atlest. I cannot reinstall the .exe once again in all the 500 machines. Any solution for this.........
|
|
|
|
|
Please do not repost the question in different forum.
You question here[^] is already get attention and answered.
If you have not gone through the guidelines for posting question then
please go through with it here[^].
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Please don't do this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hello,
I would like to ask why do I cannot display my records in my datagriview,
the database I use is sql server 2005 with ".mdf" extension. Also
if I use the wizard to add datasource I can add,delete records but when I run change
the startup form to show the records via code connection the records I think is gone or something
in my code is really wrong
The code I use is here:
Imports System.Data.SqlClient
Public Class Form2
Dim con As New SqlConnection
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
con.ConnectionString = "Data Source=.\SQLEXPRESS;" + _
"AttachDbFilename=|DataDirectory|\Database1.mdf;" + _
"Integrated Security=True;User Instance=True"
con.Open()
con.Close()
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
con.Open()
da = New SqlDataAdapter("SELECT * FROM phoneBookTable", con)
da.Fill(dt)
con.Close()
DataGridView1.DataSource = dt.DefaultView
Catch ex As Exception
MsgBox(ex.ToString)
con.Close()
End Try
End Sub
End Class
Thanks,
Dan
|
|
|
|