I'm trying to call a SQL Server 7 stored procedure that has a return
and an output parameter. I'm following an example that I was able to
find, but I'm getting an error. See *** in the following code.
I can't see what is wrong. Help!
Thanks!
Danielle
Private Sub MDIForm_Load()
Dim session_userid As String
Dim param1 As adodb.Parameter
Dim param2 As adodb.Parameter
Set cnSEI = New adodb.Connection
Set objCMD = New adodb.Command
Set adoRS = New adodb.Recordset
cnSEI.Open conDBConn
Set objCMD.ActiveConnection = cnSEI
objCMD.CommandText = "spGetUserInfo"
objCMD.CommandType = adCmdStoredProc
'set up a return parameter
Set param1 = objCMD.CreateParameter("Return", adInteger, adParamReturnValue)
objCMD.Parameters.Append param1
'set up an output parameter
Set param2 = objCMD.CreateParameter("Output", adChar, adParamOutput)
objCMD.Parameters.Append param2
***The above line produces the error
***Run-time error '3708'.
***The application has improperly defined a Parameter object.
'execute the command
Set adoRS = objCMD.Execute
'need to close the recordset before geting return and ouput parameters
Debug.Print "Program ended with return code " & CStr(objCMD(0))
Debug.Print "This is session_userid " & objCMD(1)
UserInfo.session_userid = objCMD(1)
cnSEI.Close
'update UserInfo
UserInfo.app_name = "PTO"
'set the constant that the holidays in the year is false
IsAddHolidaysModeYearInReview = False
adoEmployees.Refresh
sbrStatusBar.Panels(1) = "Employees: " & CStr(adoEmployees.Recordset.RecordCount)
End Sub