Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 ADO Activex Data Objects. 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant.

Similar presentations


Presentation on theme: "1 ADO Activex Data Objects. 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant."— Presentation transcript:

1 1 ADO Activex Data Objects

2 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant databases like Oracle or MS SQL Server. Provide flexible database front ends to users that are reliable

3 3

4 4 ADO Object Model

5 5 Connection Object Represents an open connection to the data source. Connection can be a local connection (say App.Path) or can be across a network in a client server application.

6 6 Cont… A connection object establishes a connection to a data provider and data source. – Connections have an isolation mode. Once a connection is created, it can be used to create RecordSet and Command objects.

7 7 Connection Object Properties ConnectionString-Defines in string form the location of the data source E.g. driver={SQL Server} server= bigsmile; uid=sa;pwd=pwd;database=pubs Provider-A string defining the provider of a connection object (the type of database to be connected) E.g. Provider=Microsoft.Jet.OLEDB.4.0 for Microsoft access

8 8 Cont… Mode- permissions for modifying data across the open connection. Read Write Read/Write various Share/Deny types. CursorLocation- location of the cursor engine can be client-side or server side

9 9 Connection Object Methods Close - Closes an open connection. Open - Opens a connection with the settings in the ConnectionString property.

10 10 Recordset Object The RecordSet object represents a complete set of records from an executed command or from an underlying base table in the database. RecordSet object references only one record at a time as the current record

11 11 Recordset Object Properties CursorLocation - This sets or returns the location of the cursor engine for the database. The options are client side and server side CursorType- Sets the cursor type. Which determines when and to whom database changes are immediately visible to.

12 12 Cursor Types adOpenForwardOnly – default- Changes made by others not visible adOpenKeyset-Number of records never changes, Records deleted by others are not accessible, Records added by others not visible,Updates made by others is notified adOpenDynamic- Notifications of additions, Deletions and Updations are received, Expensive in terms of memory and speed adOpenStatic-Changes made by others not visible

13 13 Cont… EOF and BOF - End Of File and Beginning Of File. When at the first record of an open RecordSet BOF will be true, when at the last EOF will be true. Fields - Returns a collection of the field objects for an open record set. Database fields can be accessed by – their name using the RecordSet!FieldName schema, – by their index RecordSet.Fields(intIndex) – sometimes by their name from the fields collection RecordSet.Fields("FieldName").

14 14 Cont… LockType – adLockReadOnly - No Updates allowed on the data fetched by the recordset – adLockPessimistic-Locks the record as soon as we edit it,Some providers may not support this – adLockOptimistic - Locks the record only when we update the record, Supported by all providers – adLockBatchOptimistic - Update a batch of records locally and then send it to server, Not all providers support this

15 15 Recordset Object Methods AddNew Close MoveNext MoveFirst MoveLast MovePrevious Open Update

16 16 Command Object A command object specifies a specific method you intend to execute on or against the data source accessed by an open connection.

17 17 Command Object Properties ActiveConnection - Defines the Connection object the command belongs to. CommandText -Contains the text of the command to be executed against a data source. Can be – a table name – a valid SQL string – the name of a stored procedure in the data source.

18 18 Cont… CommandType - Defines the type of the command. The three most commonly used would be – adCmdText – adCmdTable – adCmdStoredProc.

19 19 Command Object method Execute -Executes the query, SQL statement, or stored procedure specified in the CommandText property and returns a RecordSet object.

20 20 ADO Error Object An Error Object contains details about data access errors to a single operation involving provider ADO errors are trapped in On Error event

21 21 ADO Reference

22 22 Putting It All Together Using ADO is a three step process – Define and open a Connection to a data source – Decide what data is needed from the data source and define Command objects that will retrieve this data. – Retrieve the data required by executing the command objects and manipulate the data using RecordSet objects


Download ppt "1 ADO Activex Data Objects. 2 ADO ADO allows users to access data easily from many existing databases (such as Access or Paradox) From ODBC compliant."

Similar presentations


Ads by Google