ADO parameter object error

D

DanB

Can someone tell me why I am getting an error when appending the parameter to
the command object.

Error 3708.. Parameter object is improperly defined...

Here is my code.

Public Function CALCULATEVACATIONDAYS(ssno As String)
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim prmssn As ADODB.Parameter
Dim prmdays As ADODB.Parameter
Dim conString as string

Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
Set prmssn = New ADODB.Parameter
Set prmdays = New ADODB.Parameter

conSTRING = "DRIVER={SQL SERVER};SERVER=CLSVRSQL;DATABASE=VACATIONTRACKING"

cnn.Open conSTRING
cmd.ActiveConnection = cnn
cmd.CommandText = "SP_CALCULATIONVACATIONTAKEN"
cmd.CommandType = adCmdStoredProc
prmssn = cmd.CreateParameter("ssno", adChar, adParamInput, 9)
prmssn.Value = ssno
prmdays = cmd.CreateParameter("daystaken", adDecimal, adParamOutput)

cmd.Parameters.Append prmssn <<<< I GET THE ERROR HERE.
cmd.Parameters.Append prmdays
cmd.Execute

End Function


Stored procedure is:

CREATE PROCEDURE SP_CALCULATEVACATIONTAKEN
@ssno char(9),
@daystaken decimal OUTPUT
AS
SELECT @daystaken = SUM(QUANTITYTAKEN)
FROM TBLDAYSUSED
WHERE SSNO=@ssno AND (TYPEID = '1' OR TYPEID='2')
return
GO
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top