在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
首先是一个不需要修改的方法,拿来就用 private string ExeCommand(string commandText) System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; string strOutput = null; try p.Start(); p.StandardInput.WriteLine(commandText); p.StandardInput.WriteLine("exit"); strOutput = p.StandardOutput.ReadToEnd(); p.WaitForExit(); p.Close(); } catch (Exception e) strOutput = e.Message; } return strOutput; } 其调用方法就两句话 string sqlQuery = "osql.exe -U" + loginName + " -P" + loginPwd + " -S" + serverIp + " -d" + dbName + " -iyoursql.sql"; string strRst = ExeCommand(sqlQuery); |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论