Sunday, May 31, 2009

DataSet Vs Datareader

Before some time a reader  vamsi asked me in my increase asp.net application performance post that why should i prefer data reader over dataset. Both data reader and dataset are usually use to fetch data from the database but both are having different mechanism for fetching data from database. First we looked into that and then we decide in which condition we need to use dataset and in which condition we need to use data reader.

DataReader:

Datareader fetch data one by one from the database. You can have one row(record)  at a time in datareader. Once you read next row with read method of the datareader the older record is destroyed from memory and new record will take place instead of it. You can do that only forward only and you can not modify the data. It also require a database connection to stayed open while fetching data. You can use CommandBehavior.CloseConnection property to close connection after data reader finish reading data from database.

Dataset:

You can call dataset a mini database in your memory. Dataset support disconnected architecture as once you fill dataset with data then no connection is required. A database can contain multiple tables also its supports relationship between them. You can insert,update and delete records from dataset and you can update them also in database.

Where i should use dataset over database?

When you are required to display only data then use datareader.Dataset will fetch data once a time. So if you are having millions of records then it will consume your server memory while datareader will have just one record at a time in database. And you need not to display millions of records at time.

Following are the link from which you can find which is best suited for your need.

http://www.simple-talk.com/dotnet/.net-framework/should-you-use-ado.net-datareader-or-dataset/

http://aspnet.4guysfromrolla.com/articles/050405-1.aspx

http://www.netnewsgroups.net/group/microsoft.public.dotnet.framework.aspnet/topic740.aspx

Share:
Thursday, May 28, 2009

My blogs posts are appearing on Microsoft TechEd

Its a great honor to be part of the Microsoft TechNet and TechEd community and i have found that my blog entries are also appearing on the TechNet sites. So thanks Microsoft and TechEd editors for considering my post in TechEd blogs.

Here is link for TechEd blogs.

http://www.msteched.com/online/blogs.aspx

Share:

What is the difference between User Control and Custom Control

Custom controls are compiled code(Dlls) easier to use,difficult to create and can be place in toolbox. You can drag and drop controls, Attributes of this control are visually set at design time. A custom control can be used in multiple application as shared DLLS. Any one can copy DLL of custom control in bin directory and add reference and use them. Normally custom controls are designed to provide custom functionality independent of consuming application.

User controls are similar to those of asp include files easy to create, can not be placed into the toolbox and dragged dropped from it. A User controls can share single application files. Normally designed to provided functionality that is reusable for the particular application.

Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews