Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Am moving from VB6 to VB.net, I have a real problem to get the number of records in ADO.net, any help?

I used to use RecordSet.RecordCount property to get it. Any help ^_^ ???

user-image
Question added by Deleted user
Date Posted: 2013/08/02
OMAR ABDULWAHAB
by OMAR ABDULWAHAB , programmer , knone

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

Daanish Rumani
by Daanish Rumani , Product Manager , Publicis Sapient

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

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.