Can A recordset be returned from a Stored Procedure that starts with a Insert or Update Statement?
I use the above code to return recordesets.
Today, I am trying it on a new SP that has a couple of Insert and Update Statements when i try to run this codet it runs returns no errors does the updates ect but when i try to us the recordset
i get this error
Code:
Public Cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Function ExecuteAdoRS(AdoString As String, adoCommandType As Integer, ParamArray AdoPrams()) As ADODB.Recordset
'AdoPrams must have at least 1 value for the return value of a SP
Dim Prams As Integer
Dim a As Integer
If Cnn.State = adStateClosed Then
Cnn.ConnectionTimeout = 0
Cnn.Open CurrentProject.Connection
End If
cmd.CommandText = AdoString
Set cmd.ActiveConnection = Cnn
cmd.CommandType = adoCommandType
cmd.CommandTimeout = 0
For Prams = 0 To UBound(AdoPrams)
cmd.Parameters(Prams) = AdoPrams(Prams)
Next Prams
Set ExecuteAdoRS = cmd.Execute(a)
If adoCommandType = 4 Then AdoPrams(0) = cmd(0)
End Function
I use the above code to return recordesets.
Code:
Sub xxxx()
Dim Rst As ADODB.Recordset
Set rst = ExecuteAdoRS("SPname",4,0,.....)
End Sub
Code:
Rst.movefirst
The object you entered is not a valid Recordset property.