by Troy McDowell (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 2nd April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
ADO Count database rows Get total number of rows in a table fast even with millions of rows. Much faster than using "SELECT COUNT(*) FROM
API Declarations
' Add a reference to Microsoft ActiveX Data Objects Library
' Add a reference to Microsoft ActiveX Data Objects Library
' Code uploaded by Troy McDowell [email protected]
Dim cn As ADODB.Connection
Dim rsSchema As ADODB.Recordset
Dim rCriteria As Variant
Dim strDbPath As String
Dim strDbTable As String
Dim strDbPassword As String
strDbPath = "c:\path\to\database.mdb" ' Path to Database file
strDbTable = "Table Name" ' Table Name
strDbPassword = "Database Password" ' Database Password
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:Database Password") = strDbPassword
.Mode = adModeReadWrite
.Open strDbPath
End With
rCriteria = Array(Empty, Empty, Empty, Empty, strDbTable)
Set rsSchema = cn.OpenSchema(adSchemaIndexes, rCriteria)
Debug.Print "Total Rows: " & rsSchema.Fields("CARDINALITY").Value
rsSchema.Close
Set rsSchema = Nothing
cn.Close
Set cn = Nothing
End Sub
No comments have been posted about ADO Count database rows Get total number of rows in a table fast even with millions of rows. Much f. Why not be the first to post a comment about ADO Count database rows Get total number of rows in a table fast even with millions of rows. Much f.