Advantage of data Reader?

Answer Posted / o p yadav

To highlight the advantages of using a DataReader over the
DataSet, here’s an example of using a DataSet. The following
fills a DataSet with the results from a table, and outputs
the first field in each row:

Code=

SqlConnection conn = new SqlConnection(connectionString);
SqlDataAdapter a = new SqlDataAdapter
("select * from mytable;",conn);
DataSet s = new DataSet();
a.Fill(s);
foreach (DataRow dr in s.Tables[0].Rows)
{
Console.WriteLine(dr[0].ToString());
}

As you can see, we don’t actually start the actual
inspection of data (the foreach loop), until the whole
DataSet has been filled. There may be occasions where we may
not use all our results, or we might execute other code
while inspecting (a progress bar’s progress is a trivial
example). Using a DataSet, this can only take place after
the complete results are fetched and passed into the various
collections within the DataSet.

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the main difference between Asp.net and Vb.net?

792


What is viewstate? What does the “enableviewstate” property do?

713


In which event of the page life cycle, is the viewstate available?

696


What are all the various Estimation Techniques available ?

868


What are validator? Name the validation controls in asp.net?

733


What is the equivalent of date() and time() in asp.net?

727


benefits of migration from asp to asp.net hi frnds, i have to give presentation to a client about how useful would be migrating their project from asp to asp.net .plz give me some points which i should incorporate in my ppt thanks

1858


What are the Types of authentications in IIS

796


How you will improve web application performance?

738


What is sdlc process?

738


what is a .xap file? Explain with an example.

773


Give a few examples of page life cycle events.

877


What does uri mean?

696


What's the ASP.Net Application life cycle?

779


Which property needs to be set for script manager control to extend the time before throwing time out expection if no response is received from the server?

734