VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Gets the recordcount of an ADODB.Recordset

by RL Smith (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 14th July 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Gets the recordcount of an ADODB.Recordset

API Declarations


'General Declarations for class module
Private m_PVD As ADODB.Connection

'General Declarations of a form or Class Module
Private rsData As ADODB.Recordset
'Reference to the DSN-Less Connection Class
Private oData As MyDataClass

Rate Gets the recordcount of an ADODB.Recordset



Public Function MainDataConnection() As ADODB.Connection
Set MainDataConnection = m_PVD
End Function

Private Sub Class_Initialize()
'Create a DSN-Less connection, this one uses Pervasive WGE 8.10
' however it should work with others
  Set m_PVD = New ADODB.Connection
  m_PVD.Open "Provider=PervasiveOLEDB.8.10;Data Source=MyData" 
  'Set the connection's CursorLocation property to adUseClient
  'Don't use adUseServer else it won't work!
  m_PVD.CursorLocation = adUseClient
End Sub

Private Sub Class_Terminate()
   'Kill the connection
    m_PVD.Close
    Set m_PVD = Nothing
End Sub
'END CLASS CODE

Sub GetRecCount()
'The rest is fairly simple.
Dim strSQL As String
Dim dConn As ADODB.Connection
Set rsData = New ADODB.Recordset
Set oData = New MyDataClass
Set dConn = oData.MainDataConnection
strSQL = "SELECT * FROM FCDSTATSIX, FCDUISTAT WHERE FCTSIXDEX = IDX_COUNT ORDER BY IDX_COUNT"
'Get the records and the record count. 
rsData.Open strSQL, dConn,,, adCmdText
    For i = 0 To rsData.RecordCount           
       'Do something useful with records and recordcount
         
        rsData.MoveNext 
    Next

End Sub

Download this snippet    Add to My Saved Code

Gets the recordcount of an ADODB.Recordset Comments

No comments have been posted about Gets the recordcount of an ADODB.Recordset. Why not be the first to post a comment about Gets the recordcount of an ADODB.Recordset.

Post your comment

Subject:
Message:
0/1000 characters