Ado. NET as a tool in vb.net, with a considerable number of related objects, first of all the concept of some objects to explain:
(1) ADOConnection: This object represents an exact connection to a database, and a user can use an instance of this object by opening and closing a connection.
(2) Adocommand: This class represents an SQL command that a user will make to a database, it can return a value, or it can return a null value.
(3) Adodatasetcommand: Provides a bridge to the delivery of data in a database or a local data set.
(4) DataSet: A table representing one or more databases, or a collection of data returned after a query from a local database.
(5) DataTable: A separate table that is returned from a database or a query.
(6) DataRow: A separate column in a DataTable.
1. Connect a database
To connect to a database, a user can create a string of connection information specifically for that database. For example, to access an Access database, the concatenated string can be written as:
2. Reading data from a data table
To read data from a data table, users can create a adocommand and contain SQL expressions and connections with the appropriate parameters.
The user can then simply tell the command object to load the DataSet object through connection. The user must indicate the table name of the FillDataSet method action, as in the following code:
3. Execute a query
Executing a SELECT query is similar to the code above, except that it is more complex on a SQL query statement, as shown in the following code for the selection relationship:
4. Delete the contents of a table
Users can delete the contents of a table by using the delete * from table SQL expression. However, since there is no select expression to contact a local table, users can use the ExecuteNonQuery method of the Adocommand object:
Public Sub Delete ()