Identifying C# job failures in SQL jobs

S

stainless

I have written a C# batch windows application (.Net Framework 1.1)
that is executed via a SQL Server 2000 job step.

Everything works fine except, when my program traps a failure, I
record the error in a log, use Application.Exit, and SQL Server is
treating this as a successful step. This needs to be flagged as Failed
in the SQL job step.

How do I inform the calling step that the executable has failed? I
cannot find a means of passing a failure code or flag out of the C# (I
know I must ne missing something obvious).

Cheers

Mark
 
S

stainless

For more info, I have defined my Main class as public static int
Main(string[] args)

The final step in the Main class is

return returnValue;

where returnValue is -1 for a failure and 0 for success. I have
stepped through this and it is set up as expected. i thought this
would mean that the executable would return a code of either 0 or -1.

However, I am always getting the message "'FTPFilePull.exe' has exited
with code 0 (0x0)" regardless of whether the returnValue is -1

I know this is probably very simple but I am flummoxed at the
moment.

Cheers

Mark
 
S

stainless

One more thing.

I realise now that it should be a console application and have
recreated it as such. However, I still have the same issue regarding
the code of 0 when I return -1 in the Main section
 

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

Top