Re: Job XXX started successfully.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 07/30/04


Date: Thu, 29 Jul 2004 21:16:37 -0500

This message is informational and shouldn't raise an exception in your code.
I ran a test with the following and the job was started without problems.
Is your code similar?

Procedure:

        CREATE PROC usp_StartJob
        AS
        EXEC msdb..sp_start_job 'MyJob'
        GO

Code:

    static void Main()
    {
        try
        {
            string connectionString =
                "Data Source=MyServer;" +
                "Initial Catalog=MyDatabase;" +
                "Integrated Security=SSPI";
            SqlConnection connection =
                new SqlConnection(connectionString);
            connection.Open();
            SqlCommand command =
                new SqlCommand("usp_StartJob", connection);
            command.CommandType = CommandType.StoredProcedure;
            command.ExecuteNonQuery();
            connection.Close();
            Console.WriteLine("Done");
        }
        catch (SqlException ex)
        {
            throw new ApplicationException("usp_startjob failed: " +
                ex.ToString());
        }
        Console.ReadLine();
    }

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
" David N" <dq.ninh@netiq.com> wrote in message
news:%239btYFddEHA.3864@TK2MSFTNGP10.phx.gbl...
>
> Hi All,
>
> I have a stored procedure that is called by C# code to start a SQL agent
> job.   The stored procedure simply call the MS SQL system procedure
> msdb..sp_start_job to start the job.  The problem is that after the job
> started, the message "Job XXX started successfully." is raised and the C#
> code bomb out.
>
> Is there a way to tell SQL not to raise the message "Job XXX started
> successfully."
>
> Thanks
>
>


Relevant Pages

  • Re: What SqlExceptions can be thrown
    ... There is no case where a SqlException exception would be ... > If all you need to know is if the stored procedure you ran completed ... > have more information based on the specific errors that SQL server returns. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: question about plsql exceptions
    ... When others should be followed by a raise. ... SQL> create unique index idx_t on t; ... We know that a pl/sql block is considered an atomic operation ... Now let's introduce an exception ...
    (comp.databases.oracle.server)
  • Re: Delphi handling of SQL server generated errors
    ... Delphi should raise an Exception whenever a client ... >app that is connected to an SQL Server runs an SQL statment that ... whenever SQL Server rasies an error using the ...
    (comp.lang.pascal.delphi.misc)
  • Job XXX started successfully.
    ... I have a stored procedure that is called by C# code to start a SQL agent ... The stored procedure simply call the MS SQL system procedure ... Is there a way to tell SQL not to raise the message "Job XXX started ...
    (microsoft.public.sqlserver.programming)
  • Re: Parameterized queries
    ... That's one option but does that not then raise the issue of sql ... Hence why I turned it into a stored procedure. ...
    (microsoft.public.access.adp.sqlserver)