RecordCountの戻り値が不正


初心者  2009-03-07 15:02:11  No: 141646  IP: 192.*.*.*

初めまして。早速ですが質問させて頂きます。

下記のようなソースを作成し、後の処理で取得件数による分岐を行いたいのですが、RecordCountを使うと取得できようが出来まいが「-1」しか返ってきません。使い方間違っているのでしょうか?
ご教示いただけれ幸いです。宜しくお願いします。

Private Function selectProducts(Shakei As String, Shaban As String) As ADODB.Recordset

    Dim strSql As String
 
    strSql = "   select * " & _
             "     from d_sharyo "
              
    If Shakei <> "" Then
        strSql = strSql & "where SHAKEI_KEY = '" & Shakei & "'"
    End If
    
    If Shaban <> "" Then
        strSql = strSql & " and SHABAN = '" & Shaban & "'"
    End If
    
    Set selectProducts = oraconn.Execute(strSql)
    MsgBox (selectProducts.RecordCount)
End Function

編集 削除