I am encountering Run-time error ‘-2147467259 (80004005)” when calling the .Execute
method of my ADODB.Command
. The issue is not my connection string or it being a stored procedure. I have other stored procedures in my module that work perfectly fine, and the connection string is shared between these procedures inside the module.
Here are the relevant code sections:
Stored procedure to copy parameters:
function CopyModelParameters(a_destinationId in number, a_sourceId in Number) return number is
cursor mpvSource_cur is
select * from ModelParameterValue where model_id = a_sourceId;
mpvSource_Rec mpvSource_cur%ROWTYPE;
begin
for mpvSource_Rec in mpvSource_Cur loop
exit when mpvSource_Cur%NOTFOUND;
update ModelParameterValue
set Updated_date = SYSDATE,
CurrentValue = mpvSource_Rec.CurrentValue
where model_id = a_destinationId
and modelparameter_id = mpvSource_Rec.modelparameter_id;
end loop;
return 1;
end CopyModelParameters;
Function that defines the stored procedure in vba:
Public Sub copyModelParameterValues(ByVal targetID As Long, ByVal sourceID As Long)
connectToDB
Dim copyModelParameterValuesProc As ADODB.Command
Set copyModelParameterValuesProc = New ADODB.Command
copyModelParameterValuesProc.ActiveConnection = dbConnection
Dim returnParam As ADODB.Parameter
Set returnParam = copyModelParameterValuesProc.CreateParameter("", adVariant, adParamReturnValue, 64)
With copyModelParameterValuesProc
.Parameters.Append returnParam
.Parameters.Append copyModelParameterValuesProc.CreateParameter("@a_destinationId", adNumeric, adParamInput, 64, targetID)
.Parameters.Append copyModelParameterValuesProc.CreateParameter("@a_sourceId", adNumeric, adParamInput, 64, sourceID)
.CommandText = "ModelParameterPkg.CopyModelParameters"
.CommandType = adCmdStoredProc
'.Execute
End With
copyModelParameterValuesProc.Execute
End Sub
Where the stored procedure is called at:
Private Sub createModelButton_Click()
Dim modelBarcode, modelNumber As String
modelBarcode = targetBarCodeTextBox.Value
modelNumber = targetModelTextBox.Value
Dim activeModel As Integer
If activeCheckBox.Value Then
activeModel = 1
Else
activeModel = 0
End If
Dim newModelID As Integer
newModelID = insertNewModel(modelBarcode, modelNumber, activeModel)
Dim modelParameterRecordSet As ADODB.Recordset
Set modelParameterRecordSet = getAllModelParameters
Dim modelParameterID As Variant
Dim currentValue As Variant
If Not modelParameterRecordSet.EOF Then
Do Until modelParameterRecordSet.EOF
modelParameterID = modelParameterRecordSet.Fields("ModelParameter_ID").Value
currentValue = modelParameterRecordSet.Fields("DefaultValue").Value
insertModelParameterValue modelParameterID, newModelID, currentValue
modelParameterRecordSet.MoveNext
Loop
End If
CreateModelForm.Hide
Dim sourceModelID As Integer
If sourceComboBox.List(sourceComboBox.ListIndex, 1) Then
sourceModelID = sourceComboBox.List(sourceComboBox.ListIndex, 1)
copyModelParameterValues newModelID, sourceModelID
End If
'copyModelLimits sourceModelID, newModelID, "", "Model Copy"
getNewModelInfo newModelID
End Sub