You must Sign In to post a response.
  • Category: ASP.NET

    DataReader - Fastforward - how it is read records faster than any other object

    Hai All,

    May I know why Datareader in ADO.net is faster than other ADO.net object

    My doubt is datareader is faster than which ado.net object

    I have read that it will read record fast-forward, then which ado.net reads move backward and foward while reading the table

    Kindly explain with simple examples

    Thanks and Regards,
    A.L.Chellappan
  • #761150
    Hai Chellappan,
    Your statement is not correct:
    DataReader is the Forward-only Read-only recordset where the data will be read one by one in forward only manner. DataReader can't go and read the backward records.
    Why it is faster than any other ADO.Net objects:
    We can use DataReader or DataSet to read the records from the Database. So If we use DataReader, it reads only one record as a time while the DataSet gets all the record at once and dumps in the memory. So to get all the records, it take time rather than just read a single record and not keeping that record in memory.
    That is the reason, if you have the huge amount of the data in the database and want to read few records, DataReader will give better performance than dataset.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #761151
    Hi

    DataReader:
    1.DataReader works only when connection is
    open.
    2.DataReader read records in forward direction
    only.
    3.DataReader is connection oriented, when
    connection is close DataReader will be closed
    automatically.
    4.DataReader holds a collection of records.

    Dataset:
    1.To work with Dataset open connection is not
    required.
    2.Dataset can read records in both directions.
    3.Dataset is not connection oriented.
    4.Dataset holds collection of tables.

    Regards

    Thota Sridhar.
    If you learn from defeat..
    You haven't really lost..

    Sridhar Thota.
    Editor: DNS Forum.

  • #761154
    Hi
    Chellappan

    Data reader Forward only canot read backward records.

    Dataset

    -> Collection of n number of tables
    so we can huge records contains out dataset and datatable collection.

    But Datareader we can get single row multiple column so datareader performance quickly.

    We can easily fetch records and use them.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761156
    Hello Chellappan,

    Data Set and Data Reader both are different. So they work accordingly. Will explain you the difference why and when you should use as per your need then you will be more clear about the same.

    DataSet is a collection of in memory tables and datareader provides the ability to expose the data from database.

    Dataset :
    --> Do not need to open or close connection
    --> Data caching feature
    --> Works on disconnected architecture
    --> Returning multiple tables
    --> For small data

    Data Reader :
    --> Need to open or close connection
    --> No data caching feature
    --> Works on connected architecture
    --> Returning multiple tables in stream which is readonly and forward only for fast data accesss
    --> Return only one row after read

    Hope you understand now and it will be helpful for you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761175
    Hi,

    I hope your doubt is cleared now, using datareader you can get only 1 record at a time that is the reason it is more faster than other objects.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments