Learn something basic about ADO. Net [from programmer base camp]

Source: Internet
Author: User

The DataSet object represents a data buffer with rich functions in the memory. Dataset objects also organize data through tables, which are not connected to the original data source. We can add tables that can be obtained by reading local or remote XML files, or from any accessible system resources (including memory and other ancillary devices. We can sort, index, and filter data tables.

We can use a command to fill the DataSet object with a data set. If a data table is provided for a DataSet object in the form of a. Net set (the. NET data type with the set function is icollection), the same DataSet object can serve multiple requests from multiple connections. The DataSet object of ADO. NET is more general than the recordset of ADO. Unlike the recordset of ADO, it is an abstraction of the data source. However, the DataSet object retains a data storage that is working in the memory; it does not completely eliminate the record set function. If we only need to scroll the record set at a time and then generate an output, we should use the datareader object .. Net datareader object is similar to a record set of "only forward and read-only", but it is a highly dedicated object, so it is smaller than the record set in terms of volume and overhead. In fact, a record set can execute many different tasks, which is a rather bloated object. Compared with the recordset of ADO, datareader does not contain the code for "Housework Management", except the Code necessary to implement the function. It does not contain any other code.


Datarelation: This object represents the parent-child relationship between two tables. The relationship is established on a column with the same data type, but the column does not have to have the same precision. The link can be a, one-to-many (1: m), or multiple-to-many (M: N) relationship. The relationship can easily spread the changes to the parent record to the Child record, but this is not the default behavior.

To enable the datarelation object, we must add a foreignkeyconstraint to the constraintscollection Member of the data table to be modified. The constraintscollection Member of the able object determines what actions to perform when the value of a parent table is deleted or changed.

After the link is set, ADO. Net rejects all changes to the dataset that damage the link and generates a runtime exception. When traversing table records, call the getchildrows method to access all related rows from the connected table. The getchildrows method returns an array of datarow objects. This is a new hierarchical record navigation method, while the traditional record navigation method belongs to the sequential or random mode.

Links cannot be passed. Assume that table A is associated with table B, and table B is associated with some rows in Table C. In addition, we assume that when traversing a record of Table A, we need to access the subrecords in the existing relationship. If we want to access the table C Record corresponding to a specific record in Table B, then we cannot use the datarow object of Table B produced by the A-B relationship; instead, we must open a new table view from Table B, find the desired record, and call the getchildrows method through the relationship between table B and Table C.


Executescalar () method

Use the executescalar method to obtain a single returned data, such as statistics on the data.

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.