Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Any one suggestion about my code which is giving error. Please suggest..

C#
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
C#
No process is associated with this object.
Posted
Updated 24-Dec-13 1:21am
v3

You have called the Start method, before you set up the StartInfo properties.
 
Share this answer
 
Comments
thatraja 24-Dec-13 9:29am    
Well spotted, 5!
Daljit S. Gill 24-Dec-13 23:28pm    
Still getting error!!
Richard MacCutchan 25-Dec-13 4:29am    
Well I'm afraid my crystal ball is not working today so I have no idea what that means.
Daljit S. Gill 25-Dec-13 5:25am    
I have tried as per yours given instruction about program like but its even giving error. Please check and reply .

Thanks

Daljit S. Gill
Richard MacCutchan 26-Dec-13 5:23am    
Well, I still can't guess what you are doing or what the error is. Please think about your problem and provide proper details of what your code doea, and what results you see or don't see.
Try something like:
C#
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);
 
Share this answer
 
Thanks for help

Its working fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900