Five objects in ADO. net

Source: Internet
Author: User

In ADO. net, there are five built-in objects: connection, command, datareader, dataadapter, and dataset.

ADO. NET is mainly divided into: DataSet and. Net frameword data provisionProgram.

Three methods of the command object: executenonquery (), executereader (), executescalar ();

Executenonquery () This method is used to execute add (insert), delete (delete), modify (update) data, and return the number of rows affected by SQL statements. When set nocount on is encountered in the stored procedure, the default value is returned. When a trigger is found in the table, the returned results are different from the actual results.

Executereader () This method is used to read data in a table. It is only forward and fast (relative to dataadapter ).

Executescalar () This method is used to read the values in the first column of the First row returned by the SELECT statement. The returned value is of the object type. Consider data type conversion.

The fill () method of the dataadapter object is used to fill in the data in the dataset. The update () method can update the modified data in the dataset to the database. Before calling Update (), specify dbcommandbuilder to automatically generate the insertcommand, updatecommand, and deletecommand attributes of the dataadapter object. Note one thing before generating these command objects, that is, when new data is added to the dataset, insertcommand is generated. Otherwise, this object is not generated. When the data in the dataset is changed, the updatecommand is generated. If no modification result is returned, the object is not generated. When the data in the dataset is deleted, the deletecommand is generated, this object is not generated if no data is deleted. When no data in the dataset is changed, the value returned by calling Update () is 0. If you modify the value, several rows of records are returned.

These five built-in objects are mandatory for. NET database operations.

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.