string infile = @"C:\Users\yudm\Desktop\test\Patch.sql"; Process sqlprocess = new Process(); sqlprocess.StartInfo.FileName = "osql.exe"; sqlprocess.StartInfo.Arguments = String.Format("-U {0} -P {1} -S {2} -i {3} -d {4}", "sa", "12344321", "127.0.0.1", @infile,""); //U为用户名,P为密码,S为目标服务器的ip,infile为数据库脚本所在的路径 d为databse sqlprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; sqlprocess.Start(); sqlprocess.WaitForExit(); //等待程序执行.Sql脚本 sqlprocess.Close();
时间: 2024-10-12 11:25:33