打印本文 打印本文 关闭窗口 关闭窗口
在.net执行sql脚本的简单实现
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3118  更新时间:2007/11/14 12:57:30  文章录入:mintao  责任编辑:mintao
                   {

                            Process p = new 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;

上一页  [1] [2] [3]  下一页

打印本文 打印本文 关闭窗口 关闭窗口