Logo 
Search:

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: 2265
  

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.

Share: 

 

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
www.dotnet247.com/247reference/msgs/14/71972.aspx

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

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

www.learnasp.com/freebook/learn/datatable.aspx

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:
http://www.learnasp.com/advice/whygterows.asp
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:
www.learnasp.com/.../utilitybelt_xray.aspx

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
http://www.learnasp.com/learn/datasets.aspx

ADO.net however has really bad documentation and the web samples continue that tradition.
ADO.net Core Reference
www.amazon.com/.../learnasp
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:
www.learnasp.com/.../...belt_search_sqlclient.aspx
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:
www.learnasp.com/.../...belt_cached_sqlclient.aspx

 
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.
http://www.learnasp.com/learn/dbpooling.asp
http://www.learnasp.com/advice/roundrobin.asp
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.
www.learnasp.com/freebook/learn/caching.aspx

Some sample caching is @
www.learnasp.com/freebook/learn/cachepage.aspx
www.learnasp.com/.../...archeruc_cached_fixed.aspx
But Utility Belt supports the easiest kind of caching ala:
www.learnasp.com/.../...belt_cached_sqlclient.aspx

I am working on some upadates to those caching pages and some more caching examples keep an eye on:
http://www.learnasp.com/freebook/learn/index.aspx
specifically the
Speed / Optimization
section.

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




Tagged: