LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can not get MySQL to work from a System call

Solved!
Go to solution

With this code I can get MySQL to launch but does not recognize it as a valid statement in my C# program. It just shows prints out its help file:


System
("Mysql –h localhost –u me –password=pw < LoadDB.cmd");
0 Kudos
Message 1 of 20
(3,495 Views)

It works fine from the command line as :

Mysql –h localhost –u me –password=pw < LoadDB.cmd
0 Kudos
Message 2 of 20
(3,497 Views)

Hey erdc3,

 

It appears that the System() command has been replaced with the Process.Start() command in C#. Here's an MSDN resource page on that command: 

 

http://msdn.microsoft.com/en-us/library/aa326952(v=vs.71).aspx

 

I'd suggest trying that command. If you still have problems getting it to work, let us know!

0 Kudos
Message 3 of 20
(3,486 Views)

 tried it out with the following:

 

public static Process Start(
string Mysql -h localhost -u me -password=PW < LoadDB.sql
);

 

but get a whole bunch of errors such as :

Undiclared identifier 'puplic'

syntax error,; found 'static' expecting ';'

0 Kudos
Message 4 of 20
(3,481 Views)

May be you should try it in the appropriate forum... This one here is about LabWindows/CVI, not C#

0 Kudos
Message 5 of 20
(3,477 Views)

I am trying to make this work in my LabWindows/CVI code. Am I wrong to think that LabWindows/CVI uses C#? If not, what kind of C programing is it then?

0 Kudos
Message 6 of 20
(3,475 Views)

@erdc3 wrote:

Am I wrong to think that LabWindows/CVI uses C#?


Yes.


If not, what kind of C programing is it then?


ANSI C: http://en.wikipedia.org/wiki/LabWindows/CVI

0 Kudos
Message 7 of 20
(3,471 Views)

Thanks, now I know.

 

But now knowing that, just what code in ANSI C should I use to execute a system command as shown in my first post?

0 Kudos
Message 8 of 20
(3,469 Views)

There are three options:

 

If you want to wait for the program to exit, use the system () function in the ANSI C Library. If you want the function to return without waiting for the started program to exit, use LaunchExecutable (). If you also want to monitor whether the launched executable has terminated, use LaunchExecutableEx ().

0 Kudos
Message 9 of 20
(3,466 Views)

I have used the LaunchExecutable () to successfully start up the data base, then what I do is send a command of:

 

 FmtOut (“%S”, “USE MY_DATABASE\r\n”);

 

To send to the command line and followed by a carriage return, and it shows up as such, but nothing happens. It does not give me the myscl> prompt. Back. I have to actually hit the enter key to get the prompt back, but the command never gets executed. But then if I just type in from the keyboard USE MY_DATABASE it works.

 

How strange.

Thank you for your support you have been giving me, I am almost there. Must be some formatting I am doing wrong here?

0 Kudos
Message 10 of 20
(3,459 Views)