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
Which property is used to identify the Page is Post Back in ASP.NET?
Asp pages that worked pefectly on windows 2000 server and iis 5.0 do not work on windows 2003 server with iis 6.0. Asp.net pages work fine. Why?
Explain the asp.net page life cycle.
Can the dictionary object be created in client?s scope ?
What is Forms Authentication in ASP.NET?
What is the difference between client-side and server-side validations in ASP.NET?
How can we Validate a Controls in ASP.NET page using JavaScript?
What is the difference between page directive include and action tag include?
What are the navigation ways between pages available in ASP.NET?
What do you mean by serialize and marshalbyref?
What are Session states available and its Uses?
Is LINQ performance wise better or using sqlcommand?
How can we create Tree control in asp.net?
Can we override the enablepartialrendering property of the scriptmanager class?
Describe how passport authentication works.