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
Explain the difference between value type and reference type?
What is the good practice to implement validations in aspx page?
What are the different types of validation controls in asp.net?
How do session tokens work?
What is another word for redirect?
Define the steps to set up validation control.
What is asp.net and its advantages?
Explain the difference between AutoPostBack and IspostBack in ASP.NET?
How do you sign out from forms authentication?
Is asp.net core faster?
What is the difference between union and structure?
1.can we add connection string in global.asax?????????? 2.what are the default files included when we create new web application????
What are assemblies and namespaces and explain the difference between them ?
What is the difference between asp.net and mvc?
How does viewstate work?