29
Database Programming (using ADO) Universal Data Access Microsoft strategy for providing access to information across the enterprise. UDA provides high-performance access to a variety of relational and non-relational information sources • Text files, Spreadsheets, Relational Databases, Email Easy-to-use programming interface that is tool and language independent. Enables you to integrate diverse data sources, create easy-to-maintain solutions, and use your choice of best-of-breed tools, applications, and platform services

Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Universal Data Access– Microsoft strategy for providing access to information across the

enterprise. – UDA provides high-performance access to a variety of relational

and non-relational information sources• Text files, Spreadsheets, Relational Databases, Email

– Easy-to-use programming interface that is tool and language independent.

– Enables you to integrate diverse data sources, create easy-to-maintain solutions, and use your choice of best-of-breed tools, applications, and platform services

Page 2: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

UDA– does not require expensive and time-

consuming movement of data into a single data store,

– nor does it require commitment to a single vendor’s products

– based on open industry specifications with broad industry support, and works with all major established database platforms

Page 3: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Microsoft Data Access Components

– the key technologies that enable UDA– Data-driven client/server applications deployed over the Web or a

LAN can use these components to easily integrate information from a variety of sources, both relational (SQL) and non-relational

• These components include ActiveX Data Objects (ADO), OLE DB, and Open Database Connectivity (ODBC)

Page 4: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

ActiveX Data Objects (ADO)

• The strategic application programming interface (API) to data and information.

• ADO provides consistent, high-performance access to data and supports a variety of development needs, including the creation of front-end database clients and middle-tier business objects that use applications, tools, languages, or Internet browsers.

• ADO is designed to be the one data interface needed for single and multi-tier client/server and Web-based data-driven solution development

Page 5: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

ActiveX Data Objects (ADO)

• ADO provides an easy-to-use interface to OLE DB, which provides the underlying access to data.

• ADO implements a minimal number of layers between the front end and data source—all to provide a lightweight, high-performance interface

• ADO uses the Component Object Model (COM) automation interface - a language-neutral way of implementing objects that can be used in environments different from the one they were created in, even across machine boundaries

• VB.NET uses XML-based SOAP messaging instead of COM

Page 6: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

OLE DB

• The Microsoft strategic system-level programming interface to data across the organisation

• Standardized interface that allows programmers to use a standard set of programming tools to refer to data from any source

• OLE DB is designed for relational and non-relational information sources, including mainframe and hierarchical databases; e-mail and file system stores; text, graphical, and geographical data; custom business objects, etc.

Page 7: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

OLE DB• OLE DB defines a collection of COM interfaces that

encapsulate various database management system services.

• These interfaces enable the creation of software components that implement such services.

• OLE DB components consist of data providers, which contain and expose data; data consumers, which use data; and service components, which process and transport data (such as query processors and cursor engines).

Page 8: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• ActiveX Data Objects (ADO 2.0)• Enables your client applications to access and

manipulate data in a database [server] through any OLE DB provider

• Benefits are ease of use, high speed, low memory overhead

Page 9: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

How to Reference ADO 2.0 in Visual Basic

• To gain access to the ADO 2.0 objects in Visual Basic, set a reference to the appropriate ADO type library

• There are two ADO type libraries. One is called ADODB and is contained in MSADO15.DLL– It appears in the References dialog box (available from the Project

menu) as "Microsoft ActiveX Data Objects 2.0 Library“• The other is called ADOR and is contained in

MSADOR15.DLL– It appears in the References dialog as "Microsoft ActiveX Data

Objects Recordset 2.0 Library"

Page 10: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• The first type library (ADODB) is the larger and more feature-rich of the two

• It contains the main ADO objects and is the one used in most circumstances

• The second is a "lightweight" subset of the ADODB type library that supports only recordsets

Page 11: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

Page 12: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Connecting an ADO Data Control to a Database

• Place an ADO Data Control on the form• Properties of the ADO Data Control that must

be set:– ConnectionString: specifies the database file that

the data control will communicate with – RecordSource: specifies the table that will be

accessed

12

Page 13: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• ActiveX Data Objects (ADO)

This is the ADO control added to the toolbox

Page 14: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

Page 15: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

Sample Data Model represented in Microsoft Access

Page 16: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Student Table

Page 17: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Create an instance of the ADO control on a form

The control is named adoStudent

Page 18: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Set the CONNECTIONSTRING property

Page 19: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

Page 20: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

Page 21: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

Page 22: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Set the RECORDSOURCE property

Page 23: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Set the RECORDSOURCE property

Select a Table from the DB

Select adCmdTable

The RECORDSOURCE property is now set to tblStudent

Page 24: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Add Data-Aware (Bound) controls to the form which are used to display the fields of data in the DB table (tblStudent)

Name: txtID

Name: txtName

Name: txtAddress

Page 25: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• Set the DATASOURCE and DATAFIELD properties of each of the Text Boxes

• DATASOURCE = name of the ADO control (adoStudent)

• DATAFIELD = name of the required field in the DB table (tblStudent)

Page 26: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• The DATASORCE property

Page 27: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• The DATAFIELD property

Page 28: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Database Programming (using ADO)

• VB Front-End connected to a DB Back-End

MoveFirst

MovePrevious MoveNext

MoveLast

Page 29: Database Programming (using ADO) Universal Data Access – Microsoft strategy for providing access to information across the enterprise. – UDA provides high-performance

Data Control with two bound text boxes

29

First

Previous

Last

Next