Project release package-C # winform project creation installation package to append the mysql database together. calling cmd to execute the script is invalid.

Source: Internet
Author: User
Stringdbnamethis. context. parameters [& quot; dbname & quot;]; database name stringserverthis. context. parameters [& quot; server & quot;]; server name stringuidthis. context. parameters [& quot; user & quot;]; SQlServer username stringpwdthis. context. parameters [& quot; mysql project release package c # Project development code error correction

String dbname = this. context. parameters ["dbname"]; // database name string server = this. context. parameters ["server"]; // server name string uid = this. context. parameters ["user"]; // SQlServer username string pwd = this. context. parameters ["pwd"]; // password string path = this. context. parameters ["targetdir"]; // installation directory String appDirecroty = "C :\\ Program Files \ MySQL Server 5.6 \ bin \\"; stringBuilder sbcommand = new StringBuilder (); string directory = path + "database" + "\" + "121www. SQL "; sbcommand. appendFormat ("mysql-uroot-p123456 121www <{0}", directory); String command = sbcommand. toString (); // MessageBox. show (command); Cmd. startCmd (appDirecroty, command );

It is written in Cmd in this way.
Public class Cmd
{
///
/// Execute the Cmd command
///
/// Directory of the process to be started
/// Command to be executed
Public static void StartCmd (String workingDirectory, String command)
{
Process p = new Process ();
P. StartInfo. FileName = "cmd.exe ";
// MessageBox. Show (p. StartInfo. WorkingDirectory );
P. StartInfo. WorkingDirectory = workingDirectory;
// MessageBox. Show (p. StartInfo. WorkingDirectory );
P. StartInfo. UseShellExecute = false;
P. StartInfo. RedirectStandardInput = true;
P. StartInfo. RedirectStandardOutput = true;
P. StartInfo. RedirectStandardError = true;
P. StartInfo. CreateNoWindow = true;
P. Start ();
P. StandardInput. WriteLine (command );
// MessageBox. Show (command );
P. StandardInput. WriteLine ("exit ");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.