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

Name some asp objects?

537


Describe a bubbled event and how it is used ?

609


What are the namespace classes used in asp.net mvc? : asp.net mvc

534


What threading model used in asp and asp.net?

560


Describe in brief .net framework and its components.

538






How many types of sessions are there in asp net?

516


What is rich control in asp.net?

514


What is distributed system in asp.net?

531


What is viewstate? What does the "enableviewstateā€ property do? Whay would I want it on or off?

510


Explain the concept of View Model in MVC?

586


What is asp.net introduction?

513


If you have an application with multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers by using round-robbin load balancing. Explain which is the best approach to maintain login-in state for the users?

591


How do you create a master page?

545


What are the disadvantages of asp.net?

582


Explain about asp.net state management?

603