Maison > base de données > tutoriel mysql > le corps du texte

winform项目制作安装包想把mysql数据库一起附加进去,调用cmd执行脚本无效?

PHPz
Libérer: 2019-02-25 16:52:13
original
1441 Les gens l'ont consulté

mysql项目发布打包c#项目开发代码纠错

相关mysql视频教程推荐:《mysql教程

string dbname = this.Context.Parameters["dbname"];//数据库名称                

string server = this.Context.Parameters["server"];//服务器名称                

string uid = this.Context.Parameters["user"];//SQlServer用户名                

string pwd = this.Context.Parameters["pwd"];//密码                

string path = this.Context.Parameters["targetdir"];//安装目录                

String appDirecroty = "C:\\Program Files\\MySQL\\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);
Copier après la connexion

Cmd中是这样写的

public class Cmd
{
    /// 
    /// 执行Cmd命令
    /// 
    /// 要启动的进程的目录
    /// 要执行的命令
    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");
    }
Copier après la connexion

           

source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!