Hi all,
I'm getting the following error message when I tried to use stored procedure in VB.6. Can anyone help me?
Run-time error 91 object variable or with block variable not set
Here is my code:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Dim strconn As String
Dim MyID As Integer
Private Sub Form_Load()
strconn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ma;Password=p2008;Initial Catalog=T_DB;Data Source=NSERVERDEV"
con.Open strconn
conn_info
End Sub
Private Sub conn_info()
MyID = InputBox("Enter a Report ID")
Set cmd = New ADODB.Command
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "Update_Job_Status"
cmd.Parameters.Append cmd.CreateParameter("JobID", adNumeric, adParamInput, 5, MyID)
Set rs = cmd.Execute
If Not rs.EOF Then
lblId.Caption = rs.Fields(0)
lblRun.Caption = rs.Fields(20)
End If
Set cmd.ActiveConnection = Nothing
End Sub
Thanks,
A
I'm getting the following error message when I tried to use stored procedure in VB.6. Can anyone help me?
Run-time error 91 object variable or with block variable not set
Here is my code:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Dim strconn As String
Dim MyID As Integer
Private Sub Form_Load()
strconn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ma;Password=p2008;Initial Catalog=T_DB;Data Source=NSERVERDEV"
con.Open strconn
conn_info
End Sub
Private Sub conn_info()
MyID = InputBox("Enter a Report ID")
Set cmd = New ADODB.Command
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "Update_Job_Status"
cmd.Parameters.Append cmd.CreateParameter("JobID", adNumeric, adParamInput, 5, MyID)
Set rs = cmd.Execute
If Not rs.EOF Then
lblId.Caption = rs.Fields(0)
lblRun.Caption = rs.Fields(20)
End If
Set cmd.ActiveConnection = Nothing
End Sub
Thanks,
A