Should datareader be used for web development? Today, my loyal datareader told me why I didn't extend the data operation class of a datareader. I didn't answer his question. I just said that this is not recommended for web development. (because I told him this problem before ).
So do you want to use datareader in Web development?
First, let's take a look at the concept of datareader. (The content on msdn)
Datareader is a component designed specifically for data processing and quick data-only and read-only access. The connection object provides a connection to the data source. The command object allows you to access database commands used to return data, modify data, run stored procedures, and send or retrieve parameter information. Datareader provides high-performance data streams from data sources.
Let's take a look at the last half of msdn's explanation:
Finally, dataadapter provides a bridge between dataset objects and data sources. Dataadapter uses the command object to execute SQL commands in the data source to load data to dataset and make changes to the data in dataset consistent with the data source.
In my personal understanding, datareader is actually used for dataset database operations.
So what is dataset?
Datasetado. Net dataset is designed for data access independent from any data source. Therefore, it can be used for a variety of different data sources, for XML data, or for managing local data of applications. Dataset contains a set of one or more able objects, which are composed of data rows and data columns and primary keys, foreign keys, constraints, and link information related to data in the datatable object.
That is to say, dataset is a container that stores data to localization)
So why should I discuss this?
The reason is that datareader is always connected to the database. datareader uses a database link for data operations. instead of using dataset, you can directly close the database link and operate on the data. all operations must be performed when the link is opened. the linked resources of the database are released until the operation is closed. when the business volume is large, the database link will always open, consuming resources.
What if I want to return a value for a field? This problem is very difficult to solve, because any operation can be performed. datareader is used for efficiency, and dataadapter can be stored in dataset and returned.
I personally think that datareader is not recommended for web development.
The above are some of my younger brother's opinions, and there will certainly be something wrong. Please kindly advise and thank you. Let's give us a clear way to use datareader and dataset flexibly in Web development.
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