Title: Database Programming (using ADO)
1Database 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
2UDA
- does not require expensive and time-consuming
movement of data into a single data store, - nor does it require commitment to a single
vendors products - based on open industry specifications with broad
industry support, and works with all major
established database platforms
3Microsoft 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)
4ActiveX 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
5ActiveX 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 sourceall 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
6OLE 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.
7OLE 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).
8Database 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
9How 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"
10Database 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
11Database Programming (using ADO)
12Connecting 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
13Database Programming (using ADO)
- ActiveX Data Objects (ADO)
This is the ADO control added to the toolbox
14Database Programming (using ADO)
15Database Programming (using ADO)
Sample Data Model represented in Microsoft Access
16Database Programming (using ADO)
17Database Programming (using ADO)
- Create an instance of the ADO control on a form
The control is named adoStudent
18Database Programming (using ADO)
- Set the CONNECTIONSTRING property
19Database Programming (using ADO)
20Database Programming (using ADO)
21Database Programming (using ADO)
22Database Programming (using ADO)
- Set the RECORDSOURCE property
23Database Programming (using ADO)
- Set the RECORDSOURCE property
Select adCmdTable
Select a Table from the DB
The RECORDSOURCE property is now set to tblStudent
24Database 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
25Database 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)
26Database Programming (using ADO)
27Database Programming (using ADO)
28Database Programming (using ADO)
- VB Front-End connected to a DB Back-End
MoveLast
MoveFirst
MoveNext
MovePrevious
29Data Control with two bound text boxes
First
Last
Previous
Next