Data Reader or Dataset

If you are doing website project, which one is used dataset or data reader? Why?

Questions by nithya R   answers by nithya R

Showing Answers 1 - 6 of 6 Answers

Data reader is used to fetch data from a databaseaccording to users condition.
Data reader is used with the select statement.
For Eg.
to selecting a value from a database in our project,
 in c#.net we write,
string s="Select * from employee";

SqlCommand cmd=new SqlCommans(s,Connection string) ;

SqlConnection.Open();
SqlDataReader reader=new SqlDatareader;
reader=cmd.ExecuteReader();

if (reader.Read=True)
{
Response.Write("<script>alert('Data Selected')</script>");
SqlConnection.Close();
}

  Was this answer useful?  Yes

kirangiet

  • Aug 16th, 2010
 

There is no hard and fast rule like if it is a Web Site project we have to use Data Reader/ Dataset. Its depends on requirement. We can use both of them. We need to understand the pros and cons of both of them then we can decide.


1) Data Reader are faster as compare to Dataset.
2) You can fetch the record row by row using Data Reader. Dataset contain the entire table/tables.
3) Data Reader require the SQL connection to be open. Dataset can work in disconnected mode.
4) Dataset can contain multiple record-set where as Data Reader contain single record-set.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions