I have a problem with the following code; in the debug.print statement the value of rsJuvos.recordcount is always -1. There is nothing wrong with the data; using an alternative method of passing the SQL statement as a string works.
Can anyone spot the problem?
Private Sub GetRecords2(NINumber As String)
Dim cmdJuvos As New ADODB.Command
Dim paramNI As New ADODB.Parameter
Dim rsJuvos As New ADODB.Recordset
Set paramNI = cmdJuvos.CreateParameter
With paramNI
.Type = adChar
.Size = 9
.Direction = adParamInput
.Value = NINumber
End With
With cmdJuvos
.CommandText = "GetJuvos"
.CommandType = adCmdStoredProc
.ActiveConnection = con
.Parameters.Append paramNI
End With
Set rsJuvos = cmdJuvos.Execute
Debug.Print paramNI.Value, rsJuvos.RecordCount
Set cmdJuvos = Nothing
Set paramNI = Nothing
Set rsJuvos = Nothing
End Sub
Can anyone spot the problem?
Private Sub GetRecords2(NINumber As String)
Dim cmdJuvos As New ADODB.Command
Dim paramNI As New ADODB.Parameter
Dim rsJuvos As New ADODB.Recordset
Set paramNI = cmdJuvos.CreateParameter
With paramNI
.Type = adChar
.Size = 9
.Direction = adParamInput
.Value = NINumber
End With
With cmdJuvos
.CommandText = "GetJuvos"
.CommandType = adCmdStoredProc
.ActiveConnection = con
.Parameters.Append paramNI
End With
Set rsJuvos = cmdJuvos.Execute
Debug.Print paramNI.Value, rsJuvos.RecordCount
Set cmdJuvos = Nothing
Set paramNI = Nothing
Set rsJuvos = Nothing
End Sub