ADO Classes and objects

Source: Internet
Author: User

First,Connection class

To interact with the database, you must connect to it. The connection help indicates the database server, database name, user name, password, and other parameters required to connect to the database. The connection object is used by the command object to know which data source is executing the command.

The process of interacting with a database means that you must indicate the action you want to perform. This is done by the Command object. The developer uses the command object to send the SQL statement to the database. The command object uses the connection object to indicate which data source to connect to. Developers can use the command object alone to execute commands directly, or to pass a reference to a Command object to DataAdapter, which holds a set of commands that manipulate the set of data described below.

Second,Command object

After the successful connection with the data, you can use the command object to execute query, modify, insert, delete and other commands; The common methods for command objects are the ExecuteReader () method, ExecuteScalar () method and ExecuteNonQuery () method; Insert data The ExecuteNonQuery () method can be used to execute the insert command.

Third,DataReader class

Many data operations require developers to simply read a string of data. The DataReader object allows the developer to obtain the results from the Command object's SELECT statement. Considering the performance factor, the data returned from DataReader is fast and is just a "forward" stream of data. This means that developers can only fetch data from the data stream in a certain order. This is good for speed, but if the developer needs to manipulate the data, a better approach is to use a dataset.

Iv.DataSet Object

A DataSet object is a representation of the data in memory. It includes multiple DataTable objects, while a DataTable contains columns and rows, just like a table in a normal database. Developers can even define relationships between tables to create a master-slave relationship (parent-child relationships). Datasets are used in specific scenarios-helping to manage the data in memory and supporting the disconnection of data. The dataset is an object used by all data providers, so it does not require a special prefix like data provider.

Five,DataAdapter class

At some point the data used by developers is primarily read-only, and developers rarely need to change it to the underlying data source. The same situation requires that data be cached in memory to reduce the number of times that unchanged data is called by the database. DataAdapter helps developers to easily handle the above situations by disconnecting the model. The DataAdapter fills the DataSet object when a continuous change in the read and write operation of a database is returned to the database in a single batch. The dataaadapter contains a reference to the Connection object and automatically opens or closes the connection when the database is read or written. In addition, DataAdapter contains a command object reference to the Select, INSERT, update, and delete operations of the data. The developer will define dataaadapter for each table in the dataset, which will take care of all connections to the database for the developer. So the work the developer will do is tell DataAdapter when to load or write to the database.

Vi.type of DataTable

A DataTable is a data grid control. It can be applied to VB and ASP. It can simply bind the database without code. It has a Microsoft-style user interface. Instantiation of a DataTable and adding columns: DataTable dt = new DataTable ();d T. Columns.Add ("ID");d T. Columns.Add ("Name");D Atarow dr = dt. NewRow (); object[] Objs = {1, "Name"};d R. ItemArray = Objs;dt. Rows.Add (DR);

This.dataGridView1.DataSource = DT;

ADO Classes and objects

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.