Howdy,
I tried to fit all the gubbins I'm using in the title. I am trying to execute a stored procedure on an Oracle 10g database. To do this I use the following code:
I'm hoping that the relevent calls and bits are self explanatory. bStandAlone in the call to GetConnection causes the method to construct and set-up, but not open, a new connection.
Sadly, when I get to .Execute, Excel explodes and either puts on the standard "Send this error report" window, or throws an automation error - 'The Object invoked has Disconnected from its Clients.'
Does anyone know what's going on? I'm going to pay attention to the tread, so ask any other info you need. I'm happy to post any of the other bits of code used here if you need then.
I tried to fit all the gubbins I'm using in the title. I am trying to execute a stored procedure on an Oracle 10g database. To do this I use the following code:
Code:
Public Function ExecuteStoredProcedure(sStoredProcedure As String, ByRef vParameters() As Variant) As ADODB.Parameters
On Error GoTo Catch
Dim bRaceFlag As Boolean: bRaceFlag = False
Dim dCon As ADODB.Connection
Set dCon = Me.GetConnection(bStandAlone:=True)
If dCon Is Nothing Then Exit Function
If dCon.State <> adStateOpen Then dCon.Open
Dim dCommand As New ADODB.Command
Set dCommand.ActiveConnection = dCon
dCommand.CommandType = adCmdStoredProc
dCommand.CommandTimeout = 60000
dCommand.CommandText = sStoredProcedure
dCommand.NamedParameters = True
dCommand.Parameters.Refresh ' Does nothing!
Dim vParam As Variant
For Each vParam In vParameters
Call dCommand.Parameters.Append(vParam)
Next vParam
Call dCommand.Execute ' Crash happens here
Set ExecuteStoredProcedure = dCommand.Parameters '<-- Don't ask
Finally:
If Not bRaceFlag Then
bRaceFlag = True
End If
Exit Function
Catch:
Debug.Print "DatabaseManager::ExecuteStoredProcedure: " & Err.Description
Resume Finally
End Function
I'm hoping that the relevent calls and bits are self explanatory. bStandAlone in the call to GetConnection causes the method to construct and set-up, but not open, a new connection.
Sadly, when I get to .Execute, Excel explodes and either puts on the standard "Send this error report" window, or throws an automation error - 'The Object invoked has Disconnected from its Clients.'
Does anyone know what's going on? I'm going to pay attention to the tread, so ask any other info you need. I'm happy to post any of the other bits of code used here if you need then.