problem with system.process

P

Prashant

Hi,

this is my code, below, I am executing a batch file that in turn executes
multiple .sql files, my concern is if there is some problem with .sql files,
the calling program should get the error back, that is not happening.

do you have any idea how to trap the error with Process?

thanks,

Prashant



arrDbProperties = ConnectionString.Split(';');

arrServerName = arrDbProperties[0].Split('=');

arrDbName = arrDbProperties[1].Split('=');

dbName = arrDbName[1].Trim().ToString();

serverName = arrServerName[1].Trim().ToString();

sqlFilePath = webConfigPath + "ICE2.1Temp\\ICE2.1\\SQL\\";

batchFile = webConfigPath + "ICE2.1Temp\\ICE2.1\\SQL\\Drop_DB2.1.bat";

Process proc = new Process();

proc.EnableRaisingEvents = false;

proc.StartInfo.FileName = batchFile;

proc.StartInfo.Arguments = dbName + " " + serverName + " " + sqlFilePath;

proc.Start();

proc.WaitForExit();

proc = null;
 
G

Guest

With Process, you can get the command line output in the Standard Output of
the process object. That being said, SQL does not always output errors and
exceptions, which means you must check for errors in your batches and output
using PRINT statements to see some errors. I would look in this direction to
ensure you are getting these exceptions if you wish to fire off SQL code in
Process (ie, in a black box).


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,096
Latest member
ThurmanCre

Latest Threads

Top