+ All Categories
Home > Documents > Visual Programming CIT 737 - Info · PDF fileVisual Programming –CIT 737. ... Change in...

Visual Programming CIT 737 - Info · PDF fileVisual Programming –CIT 737. ... Change in...

Date post: 16-Mar-2018
Category:
Upload: lekhanh
View: 225 times
Download: 4 times
Share this document with a friend
36
BSc. CS Module Instructor: Mr. Abubakar, H Lecture No. 3 : Database Connectivity - DAO and ADO 2009/2010 Visual Programming CIT 737
Transcript

BSc. CS

Module Instructor: Mr. Abubakar, H

Lecture No. 3 : Database Connectivity - DAO and ADO

2009/2010

Visual Programming – CIT 737

File System Critique

File System Data Management

Requires extensive programming in third-generation

language (3GL)

Time consuming

Makes ad hoc queries impossible: user-defined queries

Leads to islands of information

2

File System Critique (con’t.)

Data Dependence

Change in file’s data characteristics requires modification of

data access programs

Must tell program what to do and how

Makes file systems cumbersome from programming and data

management views

Structural Dependence

Change in file structure requires modification of related

programs

3

File System Critique (con’t.)

Field Definitions and Naming Conventions

Selection of proper field names important

Attention to length of field names

Use of unique record identifiers

4

File System Critique (con’t.)

Data Redundancy

Different and conflicting versions of same data

Results of uncontrolled data redundancy

Data anomalies

- Modification

- Insertion

- Deletion

Data inconsistency

- Lack of data integrity

5

Database Systems

Database consists of logically related data stored in a single

repository

Provides advantages over file system management approach

Eliminates inconsistency, data anomalies, data dependency, and

structural dependency problems

Stores data structures, relationships

6

Database vs. File Systems

Figure 1.6

7

Database System Environment

Figure 1.7

8

DBMS Functions

Data dictionary management

Data storage management

Data transformation and presentation

Security management

Multiuser access control

Backup and recovery management

Data integrity management

Database language and application

programming interfaces

9

What is DAO????

DAO is an object oriented interface to Microsoft Jet database

engine which enables you to;

- access

- manipulate data programmatically in local and remote databases

DAO communicates with MS office DBs and other ODBC

compliant data sources through the Jet Engine

10

What DAO do

Data Access Objects (DAO) provides methods for:

- creating databases

- defining tables, fields, and indexes

- establishing relations between tables

- navigating and querying the database, and so on

DAO model is a collection of object classes that provide

properties and methods for database programming

DAO connects to both MS Access and ODBC

11

Overview of DAO and Jet

12

Jet Database Engine

The Jet database engine does the followings:

- allows manipulation of a Relational Database (Query Manager)

- offers a single interface that S/W use to access DBs (Jet API)

- supports security, RI, Transaction Processing, indexing, and so on

- is the part of RDBMS

13

Jet Database Engine…

This approach has the following advantages

- Simplifies access to the DB

- Insulates the DB from the underlying mechanics of

retrieving and updating data

- Affords great flexibility because the same objects,

properties and methods can be used with a wide variety of

supported DB formats

14

ODBC Driver Manager

ODBC driver manager

- is the software layer between jet Engine and ODBC drivers

- responsible for loading and unloading of appropriate drivers

- portability, Runtime binding to DS, and so on.

ODBC Driver: is a software interface that

- accepts ODBC standard queries

- passes them through to the specific application (DB Servers)

- modifying where necessary to account for application specific

database structure and format

15

Remote and ISAM manager

Remote Manager is a software solution that will allow you to

manage all your remote control connections in a single place

ISAM Manager is a software solution that will allow you to

manage all your Indexed Sequential Access Method databases

16

VB 6.0 Supported DBs

Through DAO and the JET engine, VB6 recognizes three

categories of DBs:

VB 6.0 DBs: Such as MS Access, are called native databases

- fast and easy

External DBs: these are Indexed Sequential Access Method

(ISAM) databases in several formats. E.g. dBase III, dBase IV, and

so on.

ODBC DBs: these include client/server databases that conform

to the ODBC standard, such as Microsoft SQL Server and Oracle.

17

Why DAO???

The DAO programming model provides:

- advanced resultset management

- universal programming model that can access any ODBC database

regardless of the ODBC compliance level

- universal error management

When to use DAO

- Is the only data access technology that supports 16-bit operations

- If an application must access both native Microsoft Jet and ODBC

resources, DAO is the best choice.

18

Data Access Objects (DAO)…

DAO library

Visual Basic 6.0 includes DAO version 3.51. To access these

objects, a reference must be made to the DAO object library.

- Project References

This will display the References dialog box

Select Microsoft DAO 3.6 object library and click OK

- DAO 3.51 is the "proper" library for use with Access 97

- DAO 3.6 is the one for Access 2000 and newer

19

The DAO Model

The DAO Model

20

Data Access Objects

DBEngine object: holds all other objects

- CreateWorkspace()

Workspace object: defines a session for the user, an area can hold one

or more databases

- CreateDatabase()

- OpenDatabase()

- BeginTrans()

- CommitTrans(), Rollback()

TableDef Object : describes database tables

- createIndex()

- createField()

21

Data Access Objects…

QueryDef: represents a stored SQL query statement, with zero

or more parameters, maintained in a Microsoft Jet database

- Execute()

- OpenRecordSet()

RecordSet: carries data to and from the DB

- AddNew()

- Edit()

- Update

- CancelUpdate

- Delete

22

Data Access Objects…Navigation Methods

- MoveFirst()

- MoveNext()

- MovePrevious()

- MoveLast()

- Move()

Search Methods

- FindFirst()

- FindNext()

- FindPrevious()

- FindLast()

23

Data Access Objects…

Relation object: represents a relationship between fields in

tables and queries

- CreateField()

Field object: represents a field in a table, query, relation, or

recordset

1. contains data

2. reads data from a record

3. writes data into a record

Index object: represents an index on a table in the database

24

Data Access Objects…

Parameter object: represents a value associated with a

QueryDef object

- Query parameters can be input, output, or both

Error object: contains information about an error that occurred

during a DAO operation

25

ActiveX Data Objects (ADO)

ActiveX Data Objects (ADO)

- is an Object Oriented database access technology.

- is a part of Microsoft’s Universal Data Access initiative, which

seeks to make all data sources generic

ADO uses OLEDB as its middleware

Why ADO

- ADO can be used in Visual Basic with no problem

- Easier to connect than DAO and RDO

- ADO’s performance today is much better than DAO and RDO

26

ActiveX Data Objects (ADO)…

OLE DB has three types of components

- Data providers

- Data Consumers

- Service components

Data providers:

- are application containing data that other appls need

- expose OLE DB interfaces that service components or data

consumers can access directly.eg MS SQL Server, OS component

There is also OLE DB provider for ODBC

27

ActiveX Data Objects (ADO)…

Data Consumers

- are applications that use data exposed by the DPs

- ADO is a programmatic interface for using OLE DB

- any program using ADO is an OLE DB consumer

Service Components are components of OLE DB that

- process

- transport data

these components include query processor and cursor engines

28

Why ADO???

Primary benefits of ADO

- Easy of use: b’se of flat objects model

- High speed/performance: indexed fields

- Low memory overhead : indexes and less no. of objects

- small disk footprint: less number of objects

- ADO is intended to give you a consistent interface for working

with a wide variety of data sources;

text files

ODBC relational databases

complex groups of databases

29

ADO characteristics

Characteristics of ADO

- Flat objects model: no need of hierarchical creation

- Less number of objects: compared to DAO & RDO

- Enhanced performance by recordset object : indexing

- Recordset persistence: RecSet data can be saved in a file

30

ActiveX Data Objects (ADO)…

To access ADO, VB 6.0 includes version 2.0

- a reference to the ADO object library must be included

1. Connection object

- represents an open connection to the data source

- a unique session with a datasource

Collections, properties, and methods of Conn obj

- configure a connection with a connectionString and mode properties

- specify an OLE DB provider

- open and then close connection

31

ActiveX Data Objects (ADO)…2. Command object

- used to query DB and return records in a recSet obj.

- execute an operation

- manipulate the structure of a DB

Command object helps

- define the executable text of the command using commandTextproperty

- execute a command and return results using execute()

- specify type of commands. adCmdText, adCmdTable

- manage transaction using BeginTrans, commit, RollbacTr

32

ActiveX Data Objects (ADO)…

3. The error object

- ADO objects can generate one or more errors

- these errors are normally contained in error object

Error object contains

- descriptions of an error

- error code/number

- source: an object that raised an error

33

ActiveX Data Objects (ADO)…

4. Field object

- recordset object contains fields collection

- each field object corresponds to a column in a recSet

Field objects allow to get

- name of a field

- or change field’s data using value property

- field’s characteristics: type, definedSize, etc

5. Parameter object: arguments associated with command object

- such as in WHERE and SORT BY clause

34

ActiveX Data Objects (ADO)…

6. RecordSet object

- represents entire set of records from a base table (user-input too)

- at any time, a recordset object refers to ONLY a single record

within a set of current record

- RecordCount()

- MaxRecords property

35

Brainstorming

Compare ADO and DAO by

– examining the similarity of the objects, properties, and methods

they have in common

– Looking at the gap in number of objects; why such gap arises,

and how it is compensated in ADO.

Next

– Connecting to DB using ADO Data control and Using Code

36


Recommended