473,408 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

OSQL + not responsing.

Hi

I am running a OSQL utility from my console application . iam trying to
install a huge SQL file of 5MB, i debugged my code and the application
is not responding at the following line of code
psi.FileName =
"osql.exe";
psi.Arguments = osqlArgs;
psi.UseShellExecute=false;
psi.CreateNoWindow=true;
psi.RedirectStandardOutput=true;
Process proc = Process.Start (psi);
proc.WaitForExit(); ///// NOt Responding here
{or}
proc.WaitForExit() //Not
Responding
int iSuccess = proc.ExitCode;
Any one please give some possible clue to this?
Regards
JP

Oct 6 '06 #1
5 2034

"gopal" <go*********@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
| Hi
|
| I am running a OSQL utility from my console application . iam trying to
| install a huge SQL file of 5MB, i debugged my code and the application
| is not responding at the following line of code
|
|
| psi.FileName =
| "osql.exe";
| psi.Arguments = osqlArgs;
| psi.UseShellExecute=false;
| psi.CreateNoWindow=true;
| psi.RedirectStandardOutput=true;
| Process proc = Process.Start (psi);
| proc.WaitForExit(); ///// NOt Responding here
| {or}
| proc.WaitForExit() //Not
| Responding
| int iSuccess = proc.ExitCode;
|
|
| Any one please give some possible clue to this?
|
|
| Regards
| JP
|

Calling:
proc.WaitForExit();
forces the caller to wait until the osql.exe process terminates, but this
ain't gonna happen unless you send a "quit" command to osql.

Willy.
Oct 6 '06 #2
Hi Willy

Please how can this be done..How to Quit?
Willy Denoyette [MVP] wrote:
"gopal" <go*********@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
| Hi
|
| I am running a OSQL utility from my console application . iam trying to
| install a huge SQL file of 5MB, i debugged my code and the application
| is not responding at the following line of code
|
|
| psi.FileName =
| "osql.exe";
| psi.Arguments = osqlArgs;
| psi.UseShellExecute=false;
| psi.CreateNoWindow=true;
| psi.RedirectStandardOutput=true;
| Process proc = Process.Start (psi);
| proc.WaitForExit(); ///// NOt Responding here
| {or}
| proc.WaitForExit() //Not
| Responding
| int iSuccess = proc.ExitCode;
|
|
| Any one please give some possible clue to this?
|
|
| Regards
| JP
|

Calling:
proc.WaitForExit();
forces the caller to wait until the osql.exe process terminates, but this
ain't gonna happen unless you send a "quit" command to osql.

Willy.
Oct 6 '06 #3

"gopal" <go*********@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
| Hi Willy
|
| Please how can this be done..How to Quit?
You are redirecting stdin and stdout don't you? So you have to pass a "quit"
string to osql's standard input whe done, just like you would do from the
commandline.

...
proc.WaitForExit();
proc.StandardInput.WriteLine ("quit");

Willy.


Oct 6 '06 #4
Hi Willy,

Yes, i am rdirecting the std output by giving
psi.RedirectStandardOutput=true;

but i am not redirecting the std input. and i also added the line

proc.StandardInput.WriteLine ("quit"); but still it is not responding

I was debugggng but when the control came over to
proc.StandardInput.WriteLine ("quit");
the applicn stops responsing. Agredd the SQL file as huge file of 5 MB
size and it basically creates a new database

So how can i handle the issue now?

Regards
JP
Willy Denoyette [MVP] wrote:
"gopal" <go*********@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
| Hi Willy
|
| Please how can this be done..How to Quit?
You are redirecting stdin and stdout don't you? So you have to pass a "quit"
string to osql's standard input whe done, just like you would do from the
commandline.

...
proc.WaitForExit();
proc.StandardInput.WriteLine ("quit");

Willy.
Oct 6 '06 #5


"gopal" <go*********@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
| Hi Willy,
|
| Yes, i am rdirecting the std output by giving
| psi.RedirectStandardOutput=true;
|
| but i am not redirecting the std input. and i also added the line
|
| proc.StandardInput.WriteLine ("quit"); but still it is not responding
|
| I was debugggng but when the control came over to
| proc.StandardInput.WriteLine ("quit");
| the applicn stops responsing. Agredd the SQL file as huge file of 5 MB
| size and it basically creates a new database
|
| So how can i handle the issue now?
|
| Regards
| JP
|
|
| Willy Denoyette [MVP] wrote:
| "gopal" <go*********@gmail.comwrote in message
| news:11*********************@i42g2000cwa.googlegro ups.com...
| | Hi Willy
| |
| | Please how can this be done..How to Quit?
| >
| >
| You are redirecting stdin and stdout don't you? So you have to pass a
"quit"
| string to osql's standard input whe done, just like you would do from
the
| commandline.
| >
| ...
| proc.WaitForExit();
| proc.StandardInput.WriteLine ("quit");
| >
| Willy.
|

Sorry above makes no sense, you need to wait after sending "quit", like so:

proc.StandardInput.WriteLine ("quit");
proc.WaitForExit();

But as I told you before, you are using an interactive utility wrapped by a
batch utility, which is a bad thing, really. Your program needs to act as if
it was an interactive user. That means that in principle you need to
redirect stdout and respond to the command prompts and pôssible error
messages from osql. In your case that would mean you have to wait for the
prompt to return, that is after the sql file has been executed (or when an
error message as returned), and then you can write "quit".
I would suggest you to write a simple C# program using sqlclient to execute
sql scripts instead of using osql the way you do.
Note also that when using sql2005 you should use sqlcmd instead of osql.
Willy.


Oct 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ajay Garg | last post by:
I am running the following OSQL command and capturing the return code for the error .Whenver i have an error like server not exists or uable to login I get a return code of 1 for the...
2
by: Bob | last post by:
Everybody, I've been doing a lot of on-line research and cannot find any reference to the exact problem I'm having. Let me preface this question with the fact that I'm coming from an Oracle...
2
by: Murtix Van Basten | last post by:
Hi, I have dumped a very large database from mysql (using mysqldump program) as a raw sql file. The reason was, convert this database to a MSSQL database. Since mysqldump creates the file as raw...
1
by: Alan Zhong | last post by:
hi, i had been removed the row counts and the column spaces... but i failed to remove the extra tabs between rows of data return from the osql output. how to detect the row delimiter? i noticed...
2
by: second714 | last post by:
Hi, I have several big tables with rows more than 25 mil rows and to update/delete/insert data in these tables, it can take minutes. I use BULK Insert/DELETE/Update with osql. While I run one of...
24
by: LineVoltageHalogen | last post by:
Greetings All, I was hoping that someone out there has run into this issue before and can shed some light on it for me. I have a stored procedure that essentially does a mini ETL from a source...
1
by: john_20_28_2000 | last post by:
Will osql product an SQL backup? By this I mean a text file with the transact-sql in it so I can use it to recreate the database elsewhere? Thank you.
11
by: gopal | last post by:
Hi, I am trying to call the OSQL utility from my C# console application and i am having problems i have the following code In Main method ProcessStartInfo psi = new...
7
by: gopal | last post by:
Hi, I have a console application whose purpose is to run the OSQL utility from my console application. When my application is run, the OSQL utility is started and it has to prompt for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.