Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing unique row of sp_help_job
Message
De
14/03/2002 14:25:45
Jason Dalio
Northern Interior Regional Health Board
Prince George, Colombie Britannique, Canada
 
 
À
Tous
Information générale
Forum:
Visual Basic
Catégorie:
SQL Server
Titre:
Accessing unique row of sp_help_job
Divers
Thread ID:
00632950
Message ID:
00632950
Vues:
53
I'm trying to access the sp_help_job procedure and it is driving me nuts. I am using the code below. If I comment out all of the parmeer stuff it works fine and retrieves me all of the information. But if I try to specify the job_id or job_name (only one may be sent to the sp) my recordset comes up empty. I am not receiving any errors either. I know it can see the the right records because if I mis-spell ResetTrainingLogonAttempts when calling job_name (and issue a null to job_id even though I shouldn't have to!) it tells me the job name does not exist. I've been busting my head for 4 hours on this irritating thing. Help! Please!
      Dim ADOCmd As New ADODB.Command
      Dim ADOPrm As New ADODB.Parameter
      Dim ADOCon As ADODB.Connection
      Dim ADORs As ADODB.Recordset
      Dim sParmName As String
      Dim strConnect As String
      Dim rStr As String

      On Error GoTo ErrHandler

      strConnect = "Provider=SQLOLEDB.1;Persist Security Info=False;" & _
        "User ID=sa;PWD=xxxxxxx;Initial Catalog=msdb;Data Source=xxxx"

      Set ADOCon = New ADODB.Connection
      With ADOCon
          .CursorLocation = adUseServer  
          .ConnectionString = strConnect
          .Open
      End With

      Set ADOCmd.ActiveConnection = ADOCon
      With ADOCmd
          .CommandType = adCmdStoredProc
          .CommandText = "sp_help_job"
      End With

      sParmName = "Return"
      Set ADOPrm = ADOCmd.CreateParameter(sParmName, adInteger, _
        adParamReturnValue, , 0)
      ADOCmd.Parameters.Append ADOPrm
      ADOCmd.Parameters(sParmName).Value = -1

      sParmName = "@job_id"     'Input Job_ID
      Set ADOPrm = ADOCmd.CreateParameter(sParmName, adGUID, _
        adParamInput)
      ADOCmd.Parameters.Append ADOPrm
      ADOCmd.Parameters(sParmName).Value = "{C2F59C35-FB30-4C29-9FF3-C742628CC1F5}"

      sParmName = "@job_name"     'Input Job_Name
      Set ADOPrm = ADOCmd.CreateParameter(sParmName, adVarWChar, _
        adParamInput, 128)
      ADOCmd.Parameters.Append ADOPrm
      ADOCmd.Parameters(sParmName).Value = "ResetTrainingLogonAttempts"


      Set ADORs = ADOCmd.Execute

      Do While (Not ADORs Is Nothing)
          If ADORs.State = adStateClosed Then Exit Do
          While Not ADORs.EOF
              For i = 0 To ADORs.Fields.Count - 1
                  rStr = rStr & " : " & ADORs(i)
              Next i
              Debug.Print Mid(rStr, 3, Len(rStr))
              ADORs.MoveNext
              rStr = ""
          Wend
          Debug.Print "----------------------"
          Set ADORs = ADORs.NextRecordset
      Loop

      Debug.Print "Return: " & ADOCmd.Parameters("Return").Value

      GoTo Shutdown

ErrHandler:
          Call ErrHandler(ADOCon)
          Resume Next

Shutdown:
          Set ADOCmd = Nothing
          Set ADOPrm = Nothing
          Set ADORs = Nothing
          Set ADOCon = Nothing
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform