example:
Dim con As New OledDB.OleDBConnection
con.connectionstring = "xxxxxxx"
dim ds as new dataset
dim da as oledb.oledbdataadepter
dim sql as string
sql = "SELECT * From xxx"
da = new oledb.oledbdataadepter(sql,con)
da.fill (ds,"xx")
con.close()
maxrows = ds.tables("cntct").rows.count
You can use the DataSet class and its Fill() method if you want to get all the records as well as their count. If all you need is the count then better fire a query that call the Count() SQL aggregate method.
Code samples on how to use the DataSet:
http://support.microsoft.com/kb/315974
http://www.c-sharpcorner.com/UploadFile/mahesh/ADORecSetFromADONetAM/ADORecSetFromADONet.aspx