In which conditions usage of SqlDataReader is better than Dataset and vice-versa ?

 Posted by Rajkatie on 7/3/2012 | Category: ADO.NET Interview questions | Views: 4038 | Points: 40
Answer:

Use SqlDataReader in the following conditions

•If you want to reduce the memory footprint of your application.

•Want to avoid the object creation overhead associated with the DataSet.

•Want to streamline and optimize your data access.

•Want to read row which contains BLOB (binary large object) columns.

•Wan to perform data binding with a control that support a data source which implement IEnumerable .

Use Dataset in the below condition

•Want in-memory relational view of the data for xml or non-xml manipulation.

•Want to retrieved data from multiple data source s like table,files or databases.

•Want to use the batch update facilities.

•Want to disconnected memory-resident cache of data.

•Wan to perform data binding with a control that support a data source which implement IList .


Source: MSDN | Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Premalatha on: 7/4/2012 | Points: 10
//dynamicall get our columns position in our reader
int myOrdinal = myReader.GetOrdinal["ColumnName"];


//use the discovered ordinal to retrieve the data
string myString = myReader.GetValue(myOrdinal);

Login to post response