ADO architecture:
consumer
(RECORDSET) Provider consumer provider
Cheng Ying ↗ OLEDB ← → Server ← → OLEDB ← → Database
KeySet Cursor and Dynamic Cursor execution process:
1. The database only puts the recorded key value into the result data set.
2, ADO CURSOR ENGINE access to customer needs
3, OLE Provider then access the corresponding data in the database according to the key value fields in the result data set
4, according to the data found by the key value, put the result data set
Transaction management function:
In the primary architecture application that uses ADO to process multiple data tables, you must remember to activate the transaction management to protect the updated data.
1. Activate the transaction management function:
Procedure AdodatasetBeForePost (Dataset: Dataset);
Begin
IF (not adoconnection.InTransaction) THEN
Adoconnection.begintrans;
END;
2. Determine the transaction after the data is successfully updated:
Procedure AdodataSetAfterpost (Dataset: DataSet);
Begin
IF (adoconnection.Irtransaction)
Adoconnection.committrans;
END;
3, finally, cancel the transaction when updating the data in order to correctly release system resources:
Procedure AdodatasetPosterror (Dataset: DataSet; E: EDATABASEERROR; VAR Action: TData);
Begin
Adoconnection.rollbackTrans;
Action: = DAABORT;
END;
Recordset's page positioning feature: For example, there are 1,000 data in the studio table. When the page is magnified [Pagesize], the entire data table is split into 100 different pages [PageCount]. Therefore, the page number specified by the programmer is 2, you can access 11-20 data.
AbsolutePage: Change the location of the current Page, setting this property to access data in a specific PAGE. This is a referral attribute.
PageCount: All records in the data table divides the number of pages obtained after PageSize. This is a read-only attribute.
PageSize: Specifies the number of data writes included in a data page. This is a referral attribute.
Recordset's Updatecriteria Dynamic Properties:
AdcriteriaKey: Use the key value field value only in the WHERE clause of the SQL command to find the original record.
AdcriteriaAllCols: Use all field values only in the WHERE clause of the SQL command to find the original record.
AdcriticalIaupcols: Use the key value field value in the WHERE clause of the SQL command and all modified field values to find the original record. This is the default setting for ADO.
AdcriteriatimeStamp: Use the key value field value in the WHERE clause of the SQL command and the field type in the data table is TimeStamp, to find the original record.
What is the client CURSOR, the server side CURSOR?
ADO's CursorLocation is divided into two: one is the client Cursor, and the other is the server-side Cursor.
So what is CURSORLOCATION? Simply put, where is the data stored when the client application has access some data? If these temporary data is stored in the client's ADO driver memory, managed by the client ADO engine, which is called client Cursor. Conversely, if these temporary data is stored in the backend database, managed by the backend database itself, called server-side CURSOR. Conclusion: Use Client-Side Cursor, plus a small number of multiple access methods, then your application is very efficient.
LockType: The impact on data access behavior is greater than the impact on the efficiency of the ADO. It mainly affects how the data source server locks resources and locks the number of resources.
Readonly: Read Read Lock When you use the Locate method, use the readonly type LockType to perform efficiency.
Optimistic: Optimistic lock
BatchOptimistic: batch lock
Pessimism: Pessimism
Conclusion: Do not use Perssimistic's LockType in distributed multi-layer applications or Internet / Intranet, because this is not only meaningless and will lose execution efficiency. More serious consequences will cause system deadlocks or incorrect data. Secondly, when calling the locate method to search data, the CACHESIZE is generally used between 100 and 1000, and the LockType uses Optimistic or BatchOptimistic. To achieve optimum efficiency.
Cachesize:
1. Increase Cachesize can increase the efficiency of the ADO application because this reduces the RoundTrips of the network.
2. Increasing Cachesize also added the time to start the data table, but increase the efficiency of the ADO application.
3. When the Cachesize is close to 1000, the execution efficiency of the ADO application seems to be very good in terms of time / space ratio.
ExecuteOptions:
EOASYNCEXECUTE: Executes commands in asynchronous ways.
EOASYNCFETCH: After the ADO has accessed the data specified by the cachesize, the other data is accessed in asynchronously.
EOASYNCFETCHNONBLOCICKING: ADO executes commands in asynchronously and does not hinder the execution of the application. Relative efficiency is high.
EOASYNCNORECORDS: Performs a stored procedure or command that does not return the result of the result. If any data that is executed or any data returns to the command will be discarded.
Conclusion: After the ADO is completed, the client application will be notified by an event.
ONFETCHPROGRESS: This event handler is triggered when it is set asynchronously.
OnfetchComplete: This event handler is triggered when the data is completely accessed.
PREPARED and stored procedures:
The prepared property value affects whether these SQL commands are compiled when the data source is executing the Action Query of these components. If the pre previous property value is TRUE, the data source can repeat this stored procedure as long as the data source is compiled. You don't need to compile the SQL command for the stored procedure when there is no SQL command that does not have these components, and then execute.
Sort data:
ADO data set .sort: = 'word name sort, word name sorting ...' (Sort with ASC DESC)
ADO handle error ErrorS (called error collection object)
........ .posteerror (..) ....
VAR
ADOERRORS: ERRORS;
ADOERROR: Error;
ICOUNT: INTEGER;
Begin
Adoerrors: = adoconn.erro;
For iCount: = 0 to adoerrors.count-1 dobegin
AdoError: = adoerrors.Item [iCount];
AdoError.Number [Source.Description, Helpfile.sqlState];
END;
END;
... ..
Try ... .except
Result: = FALSE;
Raise;