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
What is __ requestverificationtoken?
What is a web api? Which protocol is used in a web api?
What are the session management techniques asp net?
Why do I get error message "could not load type" whenever I browse to my asp.net web site?
Difference between using directive vs using statement?
What is globalization and localization in asp net?
Can you explain page lifecycle in net?
What is asp.net globalization?
How does a web application session work?
What is syntax code to send email from an asp.net application?
How do u optimize a query in asp.net?
How can we identify that the page is post back in asp net?
Give a few examples of page life cycle events.
What is difference between view state and session state?
Define dll hell?