Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 803897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:49:54+00:00 2026-05-14T23:49:54+00:00

Hi according to my last question here I try to write a sql editor

  • 0

Hi according to my last question here I try to write a sql editor or some thing like this,in this way I try to connect to CMD from C# and execute my command.
Now my problem is I connect to SQLPLUS after that I cant get SQLPLUS command,and the other resource I review don’t satisfy me. Please help me how after I connected to sqlplus , I can a live my process to run my sql command? right now I use this code:

//Create process
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();

//strCommand is path and file name of command to run
pProcess.StartInfo.FileName = strCommand;

//strCommandParameters are parameters to pass to program
pProcess.StartInfo.Arguments = strCommandParameters;

pProcess.StartInfo.UseShellExecute = false;

//Set output of program to be written to process output stream
pProcess.StartInfo.RedirectStandardOutput = true;

//Optional
pProcess.StartInfo.WorkingDirectory = strWorkingDirectory;

//Start the process
pProcess.Start();

//Get program output
string strOutput = pProcess.StandardOutput.ReadToEnd();

//Wait for process to finish
pProcess.WaitForExit();

I customized it. I separate the initialize, I created the process object one time I still have problem, to run the second command I use these codes for the second call:

pProcess.StartInfo.FileName = strCommand;

//strCommandParameters are parameters to pass to program
pProcess.StartInfo.Arguments = strCommandParameters;
//Start the process
pProcess.Start();

//Get program output
string strOutput = pProcess.StandardOutput.ReadToEnd();

//Wait for process to finish
pProcess.WaitForExit();

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:49:55+00:00Added an answer on May 14, 2026 at 11:49 pm

    Your question is a little confusing but I think i see your problem. First you should check out this blog post to see common issues with System.Diagnostics.Process. Your code happens to violate one that isn’t listed there. The reuse of the Process object itself.

    You need to refactor the code like:

        class MyProcessStarter
        {
            private ProcessStartInfo _startInfo = new ProcessStartInfo();
            public MyProcessStarter(string exe, string workingDir)
            {
                _startInfo.WorkingDirectory = workingDir;
                _startInfo.FileName = exe;
                _startInfo.UseShellExecute = false;
                _startInfo.RedirectStandardOutput = true;
            }
    
            public string Run(string arguments)
            {
                _startInfo.Arguments = arguments;
                Process p = Process.Start(_startInfo);
                p.Start();
                string strOutput = p.StandardOutput.ReadToEnd();
                p.WaitForExit();
                return strOutput;
            }
        }
    

    I’ve written a more complete and accurate implementation called ProcessRunner. The following demonstrates it’s usage to perform the same operation:

    using CSharpTest.Net.Processes;
    partial class Program
    {
        static int Main(string[] args)
        {
    
            ProcessRunner run = new ProcessRunner("svn.exe");
            run.OutputReceived += new ProcessOutputEventHandler(run_OutputReceived);
            return run.Run("update", "C:\\MyProject");
        }
    
        static void run_OutputReceived(object sender, ProcessOutputEventArgs args)
        {
            Console.WriteLine("{0}: {1}", args.Error ? "Error" : "Output", args.Data);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is why I'm asking this question: Last year I made some C++ code
I assume this is a simple question for you. Here we go: On my
I've got this form working, but according to my previous question it might not
Right so, according to one of my last questions here i finnaly came up
In my last question I posted some sample code on how I was trying
This might be a way too generic question, but what is the general approach
Since I didn't get the expected answer on my last question I'll try to
got a question regarding serializing classes that I've defined. I have some classes like
I am using the Maven-Shade-Plugin to create a runnable Uber-jar. According to the last
According to my previous question integration of jsf2.0 and spring 3.1 and hibernate 4.1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.