Name |
Description |
In addition to the usual events that occur for all database connection components, TADOConnection generates a number of additional events that occur during normal usage. | |
Use the ConnectionObject property of TADOConnection to access the underlying ADO connection object. Using this reference it is possible to access properties and call methods of the underlying ADO Connection object. Using the underlying ADO Connection object requires a good working knowledge of ADO objects in general and the ADO Connection object in particular. It is not recommended that you use the Connection object unless you are familiar with Connection object operations. Consult the Microsoft Data Access SDK help for specific information on using ADO Connection objects. | |
Like other database connection components, you can access the datasets associated with the connection using the DataSets and DataSetCount properties. However, dbGo also includes TADOCommand objects, which are not datasets, but which maintain a similar relationship to the connection component. You can use the Commands and CommandCount properties of TADOConnection to access the associated ADO command objects in the same way you use the DataSets and DataSetCount properties to access the associated datasets. Unlike DataSets and DataSetCount, which only list active datasets, Commands and CommandCount provide references to all TADOCommand components associated with the connection component. Commands is a... more | |
Apply pending data changes that have not yet been applied or canceled by calling the UpdateBatch method. Rows that have been changed and are applied have their changes put into the base tables on which the recordset is based. A cached row marked for deletion causes the corresponding base table row to be deleted. A record insertion (exists in the cache but not the base table) is added to the base table. Modified rows cause the columns in the corresponding rows in the base tables to be changed to the new column values in the cache. Used alone with no... more | |
Cancel pending data changes that have not yet been canceled or applied by calling the CancelBatch method. When you cancel pending batch updates, field values on rows that have been changed revert to the values that existed prior to the last call to CancelBatch or UpdateBatch, if either has been called, or prior to the current pending batch of changes. Used alone with no parameter, CancelBatch cancels all pending updates. A TAffectRecords value can optionally be passed as the parameter for CancelBatch. If any value except arAll is passed, only a subset of the pending changes are canceled.... more | |
If you are executing the command asynchronously, then after calling Execute you can abort the execution by calling the Cancel method: | |
dbGo applications use Microsoft ActiveX Data Objects (ADO) 2.1 to interact with an OLE DB provider that connects to a data store and accesses its data. One of the items a data store can represent is a database. An ADO-based application requires that ADO 2.1 be installed on the client computer. ADO and OLE DB is supplied by Microsoft and installed with Windows. An ADO provider represents one of a number of types of access, from native OLE DB drivers to ODBC drivers. These drivers must be installed on the client computer. OLE DB drivers for... more | |
One or more ADO dataset and command components can share a single connection to a data store by using TADOConnection. To do so, associated dataset and command components with the connection component through their Connection properties. At design-time, select the desired connection component from the drop-down list for the Connection property in the Object Inspector. At runtime, assign the reference to the Connection property. For example, the following line associates a TADODataSet component with a TADOConnection component. | |
ADO datasets can connect to an ADO data store either collectively or individually. When connecting datasets collectively, set the Connection property of each dataset to a TADOConnection component. Each dataset then uses the ADO connection component's connection. | |
You can control the amount of time that can elapse before attempted commands and connections are considered failed and are aborted using the ConnectionTimeout and CommandTimeout properties. ConnectionTimeout specifies the amount of time, in seconds, before an attempt to connect to the data store times out. If the connection does not successfully compile prior to expiration of the time specified in ConnectionTimeout, the connection attempt is canceled: | |
Unlike other datasets, ADO datasets can fetch their data asynchronously. This allows your application to continue performing other tasks while the dataset populates itself with data from the data store. To control whether the dataset fetches data asynchronously, if it fetches data at all, use the ExecuteOptions property. ExecuteOptions governs how the dataset fetches its records when you call Open or set Active to True. If the dataset represents a query or stored procedure that does not return any records, ExecuteOptions governs how the query or stored procedure is executed when you call ExecSQL or ExecProc. ExecuteOptions is... more | |
Filter a recordset to show only those rows that belong to a group of rows with the same update status using the FilterGroup property. Set FilterGroup to the TFilterGroup constant that represents the update status of rows to display. A value of fgNone (the default value for this property) specifies that no filtering is applied and all rows are visible regardless of update status (except rows marked for deletion). The example below causes only pending batch update rows to be visible. | |
ADO datasets support the common dataset feature of using bookmarks to mark and return to specific records. Also like other datasets, ADO datasets let you use filters to limit the available records in the dataset. ADO datasets provide an additional feature that combines these two common dataset features: the ability to filter on a set of records identified by bookmarks. | |
One advantage of using TADOConnection for establishing the connection to a data store instead of simply supplying a connection string for your ADO command and dataset components, is that it provides a greater degree of control over the conditions and attributes of the connection. The following topics describe the properties you can use to fine-tune the connection: | |
Use the ConnectOptions property to force the connection to be asynchronous. Asynchronous connections allow your application to continue processing without waiting for the connection to be completely opened. By default, ConnectionOptions is set to coConnectUnspecified which allows the server to decide the best type of connection. To explicitly make the connection asynchronous, set ConnectOptions to coAsyncConnect. The example routines below enable and disable asynchronous connections in the specified connection component: | |
There are two ways in which a TADOCommand object may use parameters:
The Execute... more | |
ADO connections are established using a specific mode, similar to the mode you use when opening a file. The connection mode determines the permissions available to the connection, and hence the types of operations (such as reading and writing) that can be performed using that connection. Use the Mode property to indicate the connection mode. The possible values are listed in the following table: ADO connection modes | |
Determine the update status of a given row by making it current and then inspecting the RecordStatus property of the ADO data component. RecordStatus reflects the update status of the current row and only that row. | |
The data retrieved via an ADO dataset component can be saved to a file for later retrieval on the same or a different computer. The data is saved in one of two proprietary formats: ADTG or XML. These two file formats are the only formats supported by ADO. However, both formats are not necessarily supported in all versions of ADO. Consult the ADO documentation for the version you are using to determine what save file formats are supported. Save the data to a file using the SaveToFile method. SaveToFile takes two parameters, the name of the file to which data... more | |
To open an ADO dataset in batch update mode, it must meet these criteria:
| |
The ADO page of the Tool palette hosts the dbGo components. These components let you connect to an ADO data store, execute commands, and retrieve data from tables in databases using the ADO framework. They require ADO 2.1 (or higher) to be installed on the host computer. Additionally, client software for the target database system (such as Microsoft SQL Server) must be installed, as well as an OLE DB driver or ODBC driver specific to the particular database system. Most dbGo components have direct counterparts in the components available for other data access mechanisms: a database connection component (... more | |
Unlike TADOQuery components, which use different methods to execute depending on whether they return a result set, TADOCommand always uses the Execute command to execute the command, regardless of whether it returns a result set. When the command returns a result set, Execute returns an interface to the ADO _RecordSet interface. The most convenient way to work with this interface is to assign it to the RecordSet property of an ADO dataset. For example, the following code uses TADOCommand (ADOCommand1) to execute a SELECT query, which returns a result set. This result set is then assigned to the... more | |
Specify commands for a TADOCommand component using the CommandText property. Like TADODataSet, TADOCommand lets you specify the command in different ways, depending on the CommandType property. Possible values for CommandType include: cmdText (used if the command is an SQL statement), cmdTable (if it is a table name), and cmdStoredProc (if the command is the name of a stored procedure). At design-time, select the appropriate command type from the list in the Object Inspector. At runtime, assign a value of type TCommandType to the CommandType property. | |
Use the Attributes property to control the connection component's use of retaining commits and retaining aborts. When the connection component uses retaining commits, then every time your application commits a transaction, a new transaction is automatically started. When the connection component uses retaining aborts, then every time your application rolls back a transaction, a new transaction is automatically started. Attributes is a set that can contain one, both, or neither of the constants xaCommitRetaining and xaAbortRetaining. When Attributes contains xaCommitRetaining, the connection uses retaining commits. When Attributes contains xaAbortRetaining, it uses retaining aborts. Check whether either retaining... more | |
ADO dataset components encapsulate the ADO Recordset object. They inherit the common dataset capabilities described in Understanding Datasets, using ADO to provide the implementation. In order to use an ADO dataset, you must familiarize yourself with these common features. In addition to the common dataset features, all ADO datasets add properties, events, and methods for the following:
| |
One approach for caching updates is to connect the ADO dataset to a client dataset using a dataset provider. This approach is discussed in Using a client dataset to cache updates. However, ADO dataset components provide their own support for cached updates, which they call batch updates. The following table lists the correspondences between caching updates using a client dataset and using the batch updates features: Comparison of ADO and client dataset cached updates | |
In the ADO environment, commands are textual representations of provider-specific action requests. Typically, they are Data Definition Language (DDL) and Data Manipulation Language (DML) SQL statements. The language used in commands is provider-specific, but usually compliant with the SQL-92 standard for the SQL language. Although you can always execute commands using TADOQuery, you may not want the overhead of using a dataset component, especially if the command does not return a result set. As an alternative, you can use the TADOCommand component, which is a lighter-weight object designed to execute commands, one command at a time. TADOCommand is intended... more | |
TADODataSet is a general-purpose dataset for working with data from an ADO data store. Unlike the other ADO dataset components, TADODataSet is not a table-type, query-type, or stored procedure-type dataset. Instead, it can function as any of these types:
| |
Before TADOCommand can execute its command, it must have a valid connection to a data store. This is established just as with an ADO dataset. See Connecting an ADO dataset to a data store for details. To execute the command, call the Execute method. Execute is an overloaded method that lets you choose the most appropriate way to execute the command. For commands that do not require any parameters and for which you do not need to know how many records were affected, call Execute without any parameters: | |
The dbGo components provide data access through the ADO framework. ADO, (Microsoft ActiveX Data Objects) is a set of COM objects that access data through an OLE DB provider. The dbGo components encapsulate these ADO objects in the Delphi database architecture. The ADO layer of an ADO-based application consists of Microsoft ADO 2.1, an OLE DB provider or ODBC driver for the data store access, client software for the specific database system used (in the case of SQL databases), a database back-end system accessible to the application (for SQL database systems), and a database. All of these must... more | |
The Recordset property provides direct access to the ADO recordset object underlying the dataset component. Using this object, it is possible to access properties and call methods of the recordset object from an application. Use of Recordset to directly access the underlying ADO recordset object requires a good working knowledge of ADO objects in general and the ADO recordset object in specific. Using the recordset object directly is not recommended unless you are familiar with recordset object operations. Consult the Microsoft Data Access SDK help for specific information on using ADO recordset objects. The RecordSetState property indicates the current state... more |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|