Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

GetRows of ADO in ADO.Net

  Asked By: Loretta    Date: Aug 19    Category: Asp.net    Views: 2234

How to achieve the Recordset.GetRows of ADO in ADO.Net

I want to put all the data of the sql into a variable so that i can loop / process on that.



6 Answers Found

Answer #1    Answered By: Sydney Thompson     Answered On: Aug 19

actually there is no built-in function to do that in ADO.Net.

Here you have a post on the ms ng which states that and provide some code to implement a GetRows method

Answer #2    Answered By: Kim Cruz     Answered On: Aug 19

Two things. A DataTable is already exactly what GetRows is.


It does disconnect from datasource after it is filled and all interactions with a DataTable require no database connectivity except when picked up and dropped off. DataTables are the benefits of GetrOws with more powers thatn array. They can be sorted, filtered and much more yet are not connected.

I was always a HUGE getrows advocate see:
and Datatables now mean that all ADO.net progammers have tho worlds greatest getrows.

Utility Belt has easy way to make array if you want mere array not Datatable if you want something slightly lighter. see the sample at:

the fragment:
dim arryNY as string(,)
utlty1.DBPopulate(strConnect,"select * from publishers where state='NY'",arryNY)
in that code is populating a 2d array from a datatable.

Answer #3    Answered By: Adelbert Fischer     Answered On: Aug 19

It was very helpful. Infact i'm seeing so much of differences in ADO.Net & the easy one ADO has to be done in a complicated way. Does ADO.Net really help in improving the performance by doing all this. What is ur opinion ?

Answer #4    Answered By: Bian Nguyen     Answered On: Aug 19

It is 6-8 faster than ADO in real world.

I disagree it's harder in ADO.net once you grasp which of the 3 tools you use to fetch:
=> ExecuteScalar www.learnasp.com/freebook/learn/executescalar.aspx
=> DataReader www.learnasp.com/freebook/learn/datareader.aspx
=> DataTable www.learnasp.com/freebook/learn/datatable.aspx

Plus Datasets generally can accomplish task recordsets did with a fraction of the code

ADO.net however has really bad documentation and the web samples continue that tradition.
ADO.net Core Reference
is a great book that will show you the correct way to do everything in an understandable way.

If you want to see the kind of easy things that can be built on top of ADO.net Utility Belt is a good example of taking ADO.net and streamlining it and cutting 80% of code out see:
for example. Given the way Classic ASP works I don't think I ever would create anything of the depth of UtiltyBelt. Too much work. But ADO.net is such a pleasure and so durn fast, I really enjoyed writing it particualrly the elegant way caching could be don thanks to many powerful ASP.net features see:

Answer #5    Answered By: Daniel Jones     Answered On: Aug 19

I will be thankful if u can give me some suggestions on the following.

in the earlier versions, I always used to open the connections & use the same connection whole through the application without closing it. in ADO.Net should i open the connection & keep it open whole through the application or open it & close it only when required. which is the most efficient way.

Answer #6    Answered By: Mercedes Andrews     Answered On: Aug 19

This was not the best approach from a Round-Robin / Connection Pooling standpoint.
Scalability is higher if you close early and open late.

in ADO.Net should i open the connection & keep it open whole through the application or open it & close it only when required. which is the most efficient way

Close it because Connection Polling still happens same way under the covers. ASP.net makes it almost impossible to get this wrong because the only "connected" data  object (the DataReader) forbids using the SAME connection for mutiple open datareaders. In fact doing it wrong is really difficult in ASP.net and really easy to do it wrong in Classic ASP.

The most efficient thing in .net is to master caching - Page Caching, Fragment Caching, Cache objects and dependencies.

Some sample caching is @
But Utility Belt supports the easiest kind of caching ala:

I am working on some upadates to those caching pages and some more caching examples keep an eye on:
specifically the
Speed / Optimization

Didn't find what you were looking for? Find more on GetRows of ADO in ADO.Net Or get search suggestion and latest updates.