Dear all,
I have been trying tu execute a SQL store procedure from vba but I always obtain the same error:
"Error Exec Funcion SPRecordSetExecSheet Nº Error: -2147217900 Description: The formal parameter "@Id" was not declared as an OUTPUT parameter but the actual parameter passed in requested output!
The code has 2 parts:
First one(that calls second one):
If nombreFilter = vbNullString And idFilter = vbNullString And sectorList = vbNullString Then
sNombreProc = "dbo.CF_fees"
If SPRecordSetExecSheet(conn, sDescError, ActiveSheet, True, sNombreProc, lNumReg, 1, 1) < 0 Then GoTo errHandler
Else
sNombreProc = "dbo.CF_fees_wog"
If SPRecordSetExecSheet(conn, sDescError, ActiveSheet, True, sNombreProc, lNumReg, 1, 1, _
"@Sectores", adVarWChar, -1, sectorList, _
"@Nombre", adVarWChar, 255, nombreFilter, _
"@Id", adVarWChar, 50, idFilter) < 0 Then GoTo errHandler
End If
The second code is:
With cmd
.ActiveConnection = conn
.CommandText = sNombreProc
.CommandType = adCmdStoredProc
' Adding params
For iCont = LBound(params) To UBound(params) Step 4
If IsMissing(params(iCont + 2)) Then
' Imprimir los valores de los parámetros
Debug.Print "Name: " & params(iCont)
Debug.Print "Type: " & params(iCont + 1)
Debug.Print "Value: " & CStr(params(iCont + 3))
.Parameters.Append .CreateParameter(params(iCont), params(iCont + 1), adParamInput, , CStr(params(iCont + 3)))
Else
' Imprimir los valores de los parámetros
Debug.Print "Name: " & params(iCont)
Debug.Print "Type: " & params(iCont + 1)
Debug.Print "Size: " & params(iCont + 2)
Debug.Print "Value: " & CStr(params(iCont + 3))
.Parameters.Append .CreateParameter(params(iCont), params(iCont + 1), adParamInput, params(iCont + 2), CStr(params(iCont + 3)))
End If
Next iCont
' Adding params to get the error description
Debug.Print "Name: " & sNombreParamDescResultSP
Debug.Print "Type: " & adVarChar
Debug.Print "Size: " & iSizeParamErrorSP
.Parameters.Append .CreateParameter(sNombreParamDescResultSP, adVarChar, adParamOutput, iSizeParamErrorSP)
Some help would be much appreciated.
Regards,
I have been trying tu execute a SQL store procedure from vba but I always obtain the same error:
"Error Exec Funcion SPRecordSetExecSheet Nº Error: -2147217900 Description: The formal parameter "@Id" was not declared as an OUTPUT parameter but the actual parameter passed in requested output!
The code has 2 parts:
First one(that calls second one):
If nombreFilter = vbNullString And idFilter = vbNullString And sectorList = vbNullString Then
sNombreProc = "dbo.CF_fees"
If SPRecordSetExecSheet(conn, sDescError, ActiveSheet, True, sNombreProc, lNumReg, 1, 1) < 0 Then GoTo errHandler
Else
sNombreProc = "dbo.CF_fees_wog"
If SPRecordSetExecSheet(conn, sDescError, ActiveSheet, True, sNombreProc, lNumReg, 1, 1, _
"@Sectores", adVarWChar, -1, sectorList, _
"@Nombre", adVarWChar, 255, nombreFilter, _
"@Id", adVarWChar, 50, idFilter) < 0 Then GoTo errHandler
End If
The second code is:
With cmd
.ActiveConnection = conn
.CommandText = sNombreProc
.CommandType = adCmdStoredProc
' Adding params
For iCont = LBound(params) To UBound(params) Step 4
If IsMissing(params(iCont + 2)) Then
' Imprimir los valores de los parámetros
Debug.Print "Name: " & params(iCont)
Debug.Print "Type: " & params(iCont + 1)
Debug.Print "Value: " & CStr(params(iCont + 3))
.Parameters.Append .CreateParameter(params(iCont), params(iCont + 1), adParamInput, , CStr(params(iCont + 3)))
Else
' Imprimir los valores de los parámetros
Debug.Print "Name: " & params(iCont)
Debug.Print "Type: " & params(iCont + 1)
Debug.Print "Size: " & params(iCont + 2)
Debug.Print "Value: " & CStr(params(iCont + 3))
.Parameters.Append .CreateParameter(params(iCont), params(iCont + 1), adParamInput, params(iCont + 2), CStr(params(iCont + 3)))
End If
Next iCont
' Adding params to get the error description
Debug.Print "Name: " & sNombreParamDescResultSP
Debug.Print "Type: " & adVarChar
Debug.Print "Size: " & iSizeParamErrorSP
.Parameters.Append .CreateParameter(sNombreParamDescResultSP, adVarChar, adParamOutput, iSizeParamErrorSP)
Some help would be much appreciated.
Regards,