I am trying to build a function that returns an RecordSet, and takes the parameters from an array argument that given it.

Let me explain it with code:

Function execRSParams (ByVal strSQL, byVal objConn, byVal aryParams)
Const adParamInput = &H0001

Set objCmd = Server.CreateObject("ADODB.Command")
Set objRS = Server.CreateObject("ADODB.RecordSet")
Set objParam = Server.CreateObject("ADODB.Parameter")

objCmd.CommandText = strSQL
objCmd.CommandType = 1 'adCmdText

For I = 0 To uBound(aryParams)
objParam = objCmd.CreateParameter("@" & strParamName, varParamType, &H0001, 32, varParamValue)
objCmd.Parameters.Append objParam
Next

Set objRS = objCmd.Execute

Set objCmd = Nothing
Set objParam = Nothing
End Function

Bu I get a stupid "Type Mismatch" error in the objCmd.Parameters.Append line.

Any ideas?