Difference between datset and datareader

Source: Internet
Author: User
Ado. net2.0 provides two objects for retrieving relational data: DataSet and datareader. Both objects can store the retrieved relational data in the memory. These two controls are often used in software development. Because these two controls are similar in usage and functionality, manyProgramThe employee mistakenly thinks that dataset and datareader can be replaced by each other. This idea is incorrect. Here we will analyze the differences between the dataset control and the datareader control.
1. Non-connection-oriented connection to the database when connecting to datset. Read all tables to the SQL Buffer Pool and disconnect from the database. Datareader is connected to the database. When reading a table, you can only read the table forward. After reading the data, the user decides whether to disconnect the table.
2. Data processing speed: DataSet reads data and processes data slowly. Datareader reading and processing speed is fast.
3. update the database after updating the data in the dataset, you can update the data back to the original database. After updating the data in datareader, there is no way to update the database.
4. Supports paging and dynamic sorting in dataset. There is no paging or dynamic sorting function in datareader.
5. The dataset occupies a large amount of memory on the IIS server. Datareader uses less memory on the IIS server.
In conclusion, dataset and datareader have their own application scenarios. If the data source control is only used to fill in the Control List as its option, or the data binding control does not need to provide the sorting or paging function, datareader should be used. If the data binding control needs to provide the sorting or paging function, you must use dataset to set page display effects such as paging sorting through dataset.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.