SQL加载器在C#中使用文本文件数据到数据库 [英] SQL loader using in C# for text file data to database

查看:60
本文介绍了SQL加载器在C#中使用文本文件数据到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于我的代码提出错误的任何一个建议。请建议..



Any one suggestion about my code which is giving error. Please suggest..

protected void btnFlatFileData_Click(object sender, EventArgs e)
    {

        System.Diagnostics.Process sysprocess = null;
       
        string myCommand = "/C SQLLDR cccsgd/cccsgd@XE CONTROL=D:\\WorkingFolder\\Ctrl.ctl";

        try
        {
            sysprocess = System.Diagnostics.Process.Start("CMD.EXE", myCommand);
            sysprocess.StartInfo.RedirectStandardOutput = false;
            sysprocess.StartInfo.FileName = myCommand;
            sysprocess.StartInfo.UseShellExecute = false;
            sysprocess.StartInfo.WorkingDirectory = @"D:\WorkingFolder";
            sysprocess.StartInfo.RedirectStandardError = true;
            sysprocess.WaitForExit();
            sysprocess.Close();
            if ((sysprocess.ExitCode == 0))
            {
                lblmsg.Text = "Success SQLLOADER completed data insertion";
            }
            else
            {
                lblmsg.Text = sysprocess.StandardError.ReadToEnd().ToString();
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message.ToString();
        }
        
    }







获取错误




Getting Error

No process is associated with this object.

推荐答案

您之前已调用开始方法你设置 StartInfo 属性。
You have called the Start method, before you set up the StartInfo properties.


尝试类似:

Try something like:
ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe", myCommand);
startInfo.RedirectStandardOutput = false;
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = @"D:\WorkingFolder";
startInfo.RedirectStandardError = true;
System.Diagnostics.Process.Start(startInfo);


感谢您的帮助



工作正常。
Thanks for help

Its working fine.


这篇关于SQL加载器在C#中使用文本文件数据到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆