120 likes | 258 Views
ADO & Recordsets. ADO Description & History. ActiveX Data Objects History 1991 ODBC Data Access Objects (DAO) for VB developers (JET) Remote Data Object (RDO) SQL, Oracle, etc (ODBC) ODBCDirect utilizing RDO OLE DB – ADO is a wrapper for OLE DB High level, object oriented interface
E N D
ADO Description & History • ActiveX Data Objects • History • 1991 ODBC • Data Access Objects (DAO) for VB developers (JET) • Remote Data Object (RDO) SQL, Oracle, etc (ODBC) • ODBCDirect utilizing RDO • OLE DB – ADO is a wrapper for OLE DB • High level, object oriented interface • Intended to replace DAO and RDO.
The Connection Object • Represents link to the data source • Directly execute statements against source • Manage transactions • Expose events to notify of completed tasks • Provides Error object/collection • ADO does not require Connection object, but it is highly beneficial to declare explicitly.
The Recordset Object • Supports data paging • Disconnected recordsets • Filtering • Sorting • Storing multiple data sets in a single object
Recordsets and ASP VBScript • Creating a Connection object • Recordset samples • Executing action queries • Cursors • Locks
Connection Object • Microsoft Access Example • Microsoft SQL Server Example
Recordset Example • http://www.jeonglee.com/ado
Cursors • Determines how you can move through the recordset • Determines properties and methods made available through recordset object • Can only be specified upon opening a recordset • Specify it using .CursorType property in recordset object or as the third parameter using .Open method • Performance considerations
Cursors • Adopenforwardonly (Value 0) Default • The data is alive but you can only move forward. • Cannot move backward or to specific record • Adopenkeyset (Value 1) • The data is alive and any record read will be the most recent data. • Adopendynamic (Value 2) • The data is alive and additions will be noticed. • Accurate recordcount. • Adopenstatic (Value 3) • The data is dead. It is like a snapshot of the data. • Accurate recordcount.
Locks • Data modification and concurrency • Choice of locking depends on business rules
Locks • AdLockReadOnly (Value 1) Default • Read-only recordset, no locking provided since data cannot be updated. • AdLockPessimistic (Value 2) • Attempts to lock record once editing starts. • AdLockOptimistic (Value 3) • Only locks the record when .Update method is used. • AdLockBatchOptimistic (Value 4) • Locks are issued when .UpdateBatch method is used.