Did you find this useful?
Socialize it today.


ADO Components

Thursday, September 20, 2012

tags ADO

ActiveX Data Objects (ADO) consists of a universal data-access structure that allows you to access various data sources, regardless of data structure, with the same programming interface. This allows developers to interface with various data sources without having to have in-depth knowledge of the structure of the data source itself. Objects within the ADO object model are used to provide all of the data storage, manipulation, and retrieval commands needed when writing an application that requires data access. In this tutorial, we will cover various ADO objects and collections.


Collections

CollectionDescription
FieldsIn a Recordset object, each of the Field objects that make up the Fields collection corresponds to a column in that Record set object. In a Record object, a Field can be an absolute or relative URL that points into a tree-structured namespace.
PropertiesAn object can have more than one Property object, which are contained in the object's Properties collection.
ParametersA Command object can have several Parameter commands to change its predefined behavior, and each of the Parameter objects are contained in the Command object's Parameters collection
ErrorsData Provider generated errors are passed to a collection of Error objects, while the Errors collection itself is contained in a Connection object. When an ADO operation creates an error, the collection is cleared and a new group of Error objects are created in the collection.


Connection Object

In order to access data from any source, a connection for that source must first be established. ADO uses the Connection object to accomplish this. The Connection object establishes a connection to an OLE DB data source. The Connection object stores information about the session and provides methods of connecting to the data store. A Connection object is used to accomplish the some of the following tasks: Select a data source and data provider, open and close a connection, manage transactions, and execute queries. Connection objects can be created explicitly or implicitly created.


Command Object

After the connection object establishes a session to the data source, instructions are sent to the data provider via the command object. The command object can send SQL queries directly to the provider through the CommandText property, send a stored procedure through the use of a Parameter object, or run a query and return the results to a dataset object via the Execute method. There are several other methods that can be used in the Command object relating to other objects, such as the Stream, RecordSet or Connection objects.


Recordset Object

The Recordset object consists of a Fields collection of individual Field objects, each with its own properties, and values. The Fields collection is a set of Field objects, which are the corresponding columns in the table. The Properties collection is a set of Property objects, which defines a particular functionality of an OLE DB provider. The RecordSet has numerous methods and properties for examining the data that exists within it.


Field Object

The Field object offers the developer complete access to the underlying data of a chosen recordset. The Field object makes available its field's name, value, data size, and attributes. The Field object represents a column in a row of results.


Record Object

The Record object can represent a single record within a Recordset object. A Record object can be obtained from a Recorset object, or it can be created as a standalone object to represent a resource such as a file or a directory. The Record object can be used to navigate hierarchical data sources such as a file directory.


Property Object

The Properties collection contains individual Property objects that allow dynamic characteristics of the data source belonging to the current data provider to be accessed within each object. This object is specific to the OLE DB provider and defines an ability that the provider has implemented.


Parameter Object

A Parameter object is generally used with a Command object. It is used to pass parameter values to the Command object. A Command object can have multiple Parameter objects attached to it. A parameter is a means of altering the behavior of a common piece of functionality, for instance a stored procedure might have different parameters passed to it depending on what needs to be done.


Transaction Object

If the OLE DB provider allows it, transactions can be used. To start the transaction, the programmer invokes the BeginTrans method and does the required updates. When they are all done, the programmer invokes the CommitTrans method. RollbackTrans can be invoked to cancel any changes made inside the transaction and rollback the database to the state before the transaction began.


Stream Object

The Stream object is mainly used in a Recordset object. It can be used to view and manipulate text and binary data belonging to a resource such as a file or a buffer in memory. A Stream object can be obtained from a Record object or it can be created as a standalone object.


Error Object

When an OLE DB provider error occurs during the use of ADO, an Error object will be created in the Errors collection. The Errors collection contains errors and warnings that are generated both by ADO and by the individual data provider being used. An Error object provides a description of the error, an error number, the name of the object that generated the error, and error information from SQL data sources.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

ADO: ActiveX Data Objects ADO Programming for Dummies ADO Programmers Reference