|
Hi, I am trying to write a console program that among other things will use the sqlplus utility to run PL/SQL script in a file.
To this end I have the following bit of code:
<pre>
static void execute(string command, string args, int timeout, string process_title)
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(command, args);
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
System.Diagnostics.Process ps;
try
{
ps = System.Diagnostics.Process.Start(psi);
if(!ps.WaitForExit(timeout))
{
try
{
ps.Kill();
}
catch(Exception e)
{
log("Error while trying to terminate process");
log("Error: "+e.Message);
}
throw new Exception(process_title+" operation has timed out.");
}
}
catch(Exception e)
{
log("Error Running "+process_title);
throw e;
}
}
</pre>
However when I run
execute("sqlplus", @"mylogin/mypassword@sid @filepath", 50000, "my process");
I get a timeout, even if the file only contains a simple and small select clause.
Any ideas?
I suspect this is not sqlplus related since running
execute("dir", @"C:\", 1000, "dir");
results in a "The system cannot find the file specified" error
|
|
|
|
|
Can you not use the oracle drivers in .NET and execute the script through the common runtime?
The reason you get the time out is because the application is likely waiting for input. I believe there is a WaitForInputIdle method which might suit you better.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
"dir" cannot be executed because there is no "dir.exe", it is just a command supported by cmd.exe.
Can you try to disable RedirectStandardOutput? If you don't get a timeout then, your application is not handling the output fast enough. (the "sqlplus" process will pause when the output buffer is full)
|
|
|
|
|
Yes, disabling redirect standard output works fine.
Is there a way to deal with this short of editing the script file itself to turn spooling on?
I would like the equivalent of 'sqlplus user/pass@sid @scriptfilename > logfilename', but not surprisingly, appending '> logfilename' to the arguments string doesn't work.
|
|
|
|
|
Found the answer here:
http://weblogs.asp.net/israelio/archive/2004/08/31/223447.aspx how to pipe to a process
just launch cmd.exe and pass everything to it as a parameter.
Works great for me, anyone have any idea if this might be inferior for any reason? Why should I not just write a wrapper to launch all my prcoesses this way?
|
|
|
|
|
How do i set a menu button to change the webpage to another.
Not a ComboBox, just a regular Menu Button to change my web browsers page.
Also I've seen programs with a Check box button that if clicked the window will always be on top. What code would i need to put into that?
|
|
|
|
|
The answer to your second question:
Add a checkbox to your form, and set it's CheckStateChanged event handler.
Write the following code within the event handler:
if (checkBox1.Checked == true)
{
this.TopMost = true;
}
else
{
this.TopMost = false;
}
And that's it.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Thanks Virtual1ty
|
|
|
|
|
You're welcome
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
What about
this.TopMost = checkBox1.Checked
?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Oh yeah, I didn't think about that
Virtual1ty "Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
C# Beginner Nick wrote: to change my web browsers page.
Do you mean the browser that's installed on your pc, or is it a webbrowser component on your form?
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Component on my Form,
And the buttons are in the Menu Strip.
|
|
|
|
|
Then you can use the WebBrowser component's Navigate() method in the button's event handler. For example:
WebBrowser1.Navigate("http://www.codeproject.com");
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Ohh ok i understand. Thanks again Virtual1ty
|
|
|
|
|
Glad to help you
Virtual1ty "Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Thanks again, even though I already thanked you twice.
Thought I'd say thanks again because I just now finished the program I was creating becuase of you're help
It allows me to view every episode of Yu Yu Hakusho
I made it for my sister becuase she loves the show and i wanted to try something new.
|
|
|
|
|
I am after writing a C# program which gives details of the NTFS file system. It also offers the chance to do basic undelete. However I have discovered that when you start a .NET 2 program a file with a long alphanumeric name is created and deleted in the system32/temp directory. Is it possible to prevent this as it poses a threat to successful undeleting.
Thanks in Advance
Liam
|
|
|
|
|
Don't parse the temp folders. Even in linux applications make heavy use of temp folders files.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
how to connect MS acess with C#.NET
|
|
|
|
|
s4_sabahatf wrote: how to connect MS acess with C#.NET
The real question is are you capable of looking at the list of C# Database Articles here on CodeProject that surely contain the answers you seek?
|
|
|
|
|
Have a look at this website: http://www.connectionstrings.com/
|
|
|
|
|
Use a connection string. Like Giorgi said, go to http://www.connectionstrings.com[^], better yet, bookmark the site
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I think I read (or dreamed and hoped) that there was an attribute you could use on a class to disable the designer support. Specifically, write a class that inherits a control or datarow or anything with a designer and double clicking on the class file then defaults to design mode. Sometimes I never want the designer.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Hi,
I usually add the line
[System.ComponentModel.DesignerCategory("Code")]
right above the class statement for this.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|