is there a way to append parameters to a command in a loop. In a way that you dont have to specify:
- the parameter name
- the datatype
- the parameter type
- the size of the parameter
- the value going into the parameter
as hardcoded items - rather can you use variables to set these
what i was thinking was using an Generic function like this:
'*************************
**********
**********
***
Public Sub ExecuteParameter(sStoredPr
ocedure As String, _
arrParameters() As String)
Dim iCounter As Integer
dim objSQLCommand as ADODB.command
Set objSQLCommand = New ADODB.Command
objSQLCommand.ActiveConnec
tion = objSQLConnection
objSQLCommand.CommandType = adCmdStoredProc
objSQLCommand.CommandText = sStoredProcedure
For iCounter = 0 To UBound(arrParameters(), 2)
objSQLCommand.Parameters.A
ppend _
objSQLCommand.CreateParame
ter(arrPar
ameters(0,
iCounter), _
arrParameters(1, iCounter), _
arrParameters(2, iCounter), _
arrParameters(3, iCounter), _
arrParameters(4, iCounter))
Next iCounter
objSQLCommand.Execute
Set objSQLCommand = Nothing
End Sub
'*************************
**********
**********
***
The problem is it seems that when you say
objSQLParameter.createpara
meter - the arguments that follow must be Hardcoded - so i cannot just use an array to hold the values.
Is there a way around this?
thanks
Start Free Trial