3001 Arguments are of the wrong type

E

Edward

I have a wrapper function for executing a SQL Server Stored Procedure
that returns no records:

Public Function modRunStoredProc(vstrSPName As String, ParamArray
vvarParams() As Variant) As Variant

On Error GoTo modRunOutputStoredProc_Err

Dim cmd As Command
Dim intIndex As Integer
Dim intParamIndex As Integer
Dim varRecsAffected As Variant

' This routine returns no outputs - varRecsAffected is simply the
number of rows affected by the SPROC
modRunStoredProc = Null

' Create command
Set cmd = New ADODB.Command
cmd.ActiveConnection = gtypUserDetails.prpOLEDBConnectString
cmd.CommandText = vstrSPName
cmd.CommandType = adCmdStoredProc

' Build parameters
intParamIndex = 0
For intIndex = 0 To UBound(vvarParams()) Step 5
cmd.Parameters.Append
cmd.CreateParameter(vvarParams(intIndex), vvarParams(intIndex + 1),
vvarParams(intIndex + 2), vvarParams(intIndex + 3))
If vvarParams(intIndex + 2) = adParamInput Then
cmd(intParamIndex).Value = vvarParams(intIndex + 4)
intParamIndex = intParamIndex + 1
End If
Next intIndex

' Execute stored procedure
cmd.Execute varRecsAffected, , adExecuteNoRecords

' Return
modRunStoredProc = varRecsAffected

modRunOutputStoredProc_Exit:
Set cmd = Nothing
Exit Function

modRunOutputStoredProc_Err:

' Get ADO Errors
Dim er As ADODB.Error, strErrNumber As String, strErrDescription
As String
strErrNumber = "Number: "
strErrDescription = "Detail: "
For Each er In cmd.ActiveConnection.Errors
strErrNumber = strErrNumber & "(" & er.Number & ") "
strErrDescription = strErrDescription & "(" & er.Description &
") "
Next
MsgBox "Server Update Problem:" & vbNewLine & strErrNumber &
vbNewLine & strErrDescription, vbOKOnly + vbExclamation,
APPLICATION_TITLE
Resume modRunOutputStoredProc_Exit

End Function

If I try to execute this:

varCDRID = modRunStoredProc("stpSetCDRFromIntranetToProcessed"
@IntranetCDRID", adInteger, adParamInput, CLng(4),
CVar(Me!fldIntranetCDRID))

I get the following errors (depending on where you look!)
"3134 Syntax error in INSERT INTO statement"

"3001 Arguments are of the wrong type, are out of acceptable range, or
are in conflict with one another."

HOWEVER, if I run this:

Dim lngSize As Long
Dim varID As Variant
Dim strParam As String

strParam = "@IntranetCDRID"
lngSize = 4
varID = Me!fldIntranetCDRID

varCDRID = modRunStoredProc("stpSetCDRFromIntranetToProcessed",
strParam, adInteger, adParamInput, lngSize, varID)

it works fine.

Anyone got a clue why?

Thanks

Edward
 

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