Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Code Value

Status
Not open for further replies.

itsmarkdavies

Programmer
Joined
May 22, 2001
Messages
87
Location
GB
I am running a JOB in SQL Server 2000 from VB using the Stored Procedure "sp_start_job", and I need to grab the Return Code Value from the Job to know if it was successful. Can anyone give me the VB code to do this ? Thanks.

Dim Cmd As New ADODB.Command
Dim Conn As ADODB.Connection
Dim Param As ADODB.Parameter
Dim strJobName As String

Set Conn = New ADODB.Connection
ConnectionString = "driver={SQL Server};server=SQL1;uid=sa;pwd=;database=msdb"
Conn.ConnectionTimeout = 60
Conn.Open ConnectionString

strJobName = "JOB_TEXT1"

Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = Conn

Cmd.CommandText = "sp_start_job @job_Name='" & strJobName & "'"
Cmd.CommandType = adCmdText
Cmd.CommandTimeout = 60

Cmd.Execute

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top