First glance at ADO.net-two ways to access data

Source: Internet
Author: User

1. Non-connection mode (dependent on datasets)
2. Connection Mode (directly operate on the database)

You can use a command object to execute SQL statements or stored procedures. If the execution result returns a record set, you can use the DataReader (data reader) object to read data. Note that the connection mode of DataReader ADO. NET can only return forward and read-only data, which is determined by the characteristics of the DataReader object.
Non-Connection Mode
In the dataset mode, the basic process of data operation is to first use the data adapter to load data into the memory (DataSet object) and operate data in the DataSet object, then, use the data adapter to write the changes to the database.
In our experience, the non-connection mode greatly reduces the frequency of connection occupation.
So what is the biggest difference between the two?
After using the two, we know that the connection mode is used to access the database for data operations, and the connection to the server needs to be maintained, it will add a burden on the server (this burden may be the occupation of the connection path or the burden of processing data), until the end of the connection load will disappear, if this connection is created too many times within a certain period of time, the server will be exhausted. Instead of the connection method, access data, connect to the database first, copy the data to be processed to the local memory, and then you can disconnect the database server, in this way, the burden on data processing is transferred to the processor of the local machine, which reduces the burden on the server and enables the server to exert higher usage. This comparison is based on the server load.

The data size is small, the system size is small, and the client and server are in the same network environment. If read-only, DataReader is preferred.
2. Non-connection
Suitable for networks with large network data volumes, multiple system nodes, and complex network structures, especially those connected through the Internet/Intranet. To bind a data source, you must modify the data and update it to the database (not connected)

Related Article

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.