In C#, a DataSet uses a DataReader to populate itself. By definition, a DataReader is basic and efficient access method to access data and return result as they become available. A DataSet, on the other hand, has to wait for the entire query to process.
The Advantages of the DataReader Example of code:
SqlConnection sql= new SqlConnection(connectionString);
SqlDataAdapter a = new SqlDataAdapter
("select * from mytable;",sql);
DataSet ds = new DataSet();
a.Fill(ds);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Console.WriteLine(dr[0].ToString());
}
The foreach loop does not begin until the DataSet is populated. This means any conditional checks or manipulations must occur in the query or after the DataSet is filled.
web developers atlanta