GreenyMcDuff
Active Member
- Joined
- Sep 20, 2010
- Messages
- 313
Hi all,
Having a strange one here and can't find a solution on google.
I'm using an ADO object to pull data from an Oracle database.
My command object is set to open a recordset that gets populated from a stored procedure as follows:
This returns a recordset with 152 fields and 96 records. When the below line executes:
I get the error: 'CopyFromRecordset' of object 'Range' failed
The strange thing is, if I Debug and press F5 the code executes and continues successfully without displaying the error again.
This code works for 95% of the parameters I use which leads me to think there must be some constraints about what types of data you can populate a recordset with. If this is the case does anyone know what the constraints are?
Thanks
Chris
Having a strange one here and can't find a solution on google.
I'm using an ADO object to pull data from an Oracle database.
My command object is set to open a recordset that gets populated from a stored procedure as follows:
Code:
Dim cmd As New ADODB.Command: Set cmd = New ADODB.Command
Set cmd.ActiveConnection = dbConnection
cmd.Properties("PLSQLRSet") = True
Dim param1 As New ADODB.Parameter
Set param1 = cmd.CreateParameter("I_PORTF_CODE", adVarChar, adParamInput, Len("GBH-" & portfCode), "GBH-" & portfCode)
cmd.Parameters.Append param1
Dim param2 As New ADODB.Parameter
Set param2 = cmd.CreateParameter("I_CONFIG_CODE", adVarChar, adParamInput, Len(configCode), configCode)
cmd.Parameters.Append param2
Dim param3 As New ADODB.Parameter
Set param3 = cmd.CreateParameter("I_END_DATE", adDBDate, adParamInput, , endDate)
cmd.Parameters.Append param3
Dim param4 As New ADODB.Parameter
Set param4 = cmd.CreateParameter("I_PERIOD", adVarChar, adParamInput, Len(period), period)
cmd.Parameters.Append param4
cmd.CommandText = "{CALL UD_MRT_ATTR_DATA_TEST(?,?,?,?)}"
Dim resultsSet As ADODB.Recordset: Set resultsSet = New ADODB.Recordset
With resultsSet
.ActiveConnection = dbConnection
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open cmd
End With
cmd.Properties("PLSQLRSet") = False
Set GetATTRDataFromBOne = resultsSet
Exit Function
This returns a recordset with 152 fields and 96 records. When the below line executes:
Code:
ws.Cells(2, 1).CopyFromRecordset rs
I get the error: 'CopyFromRecordset' of object 'Range' failed
The strange thing is, if I Debug and press F5 the code executes and continues successfully without displaying the error again.
This code works for 95% of the parameters I use which leads me to think there must be some constraints about what types of data you can populate a recordset with. If this is the case does anyone know what the constraints are?
Thanks
Chris