Using the Data Access Controls: DAO & ADO Presented by Victor Matos.
-
date post
21-Dec-2015 -
Category
Documents
-
view
218 -
download
2
Transcript of Using the Data Access Controls: DAO & ADO Presented by Victor Matos.
![Page 1: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/1.jpg)
Using the Data Access Controls: DAO & ADO
Presented by Victor Matos
![Page 2: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/2.jpg)
VB & Database Systems
New Technologies in VB6
ActiveX Data Objects (ADO)
DataList and DataCombo replace DBList and DBCombo .
The DataGrid is the successor to DBGrid.
The Chart control is now data bound.
New Hierarchical FlexGrid
The Data Report is a new ActiveX designer
Data Formatting and Data Validation
DHTML and Data Access
![Page 3: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/3.jpg)
DAO Control
Previous versions of VB used the Data Access Object Control: DAO.
DAO is/was particularly good for MS-
Access and MS-SQL-Server databases.
DAO has limitations in dealing with
non-Microsoft databases.
![Page 4: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/4.jpg)
DAO Connections
VB- Program DAO Control
MS
Jet
Engine
MS-Access
Database
ORACLE
ODBCSQLPassThrough-Mode
![Page 5: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/5.jpg)
Terminology
RECORDSET Represents the data in a table, or the
result of a SQL select statement.
You can use recordsets to view, update, or delete data in the base tables.
![Page 6: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/6.jpg)
Using the Old DAO Control
Data Aware Text Boxes
Data Aware OLEContainer
DAOData Access Control
MOVE:First, Last,Next,Previous
![Page 7: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/7.jpg)
Making the DAO Application
Make the following formControl Names:
• txtFirstName
• txtLastName
• txtID
• lblID
• olePhoto
• datEmployee
![Page 8: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/8.jpg)
datEmployee: DAO
Change the following attributes of datEmployee
Name: datEmployee DatabaseName: Nwind.mdb RecordSource: Employees Caption: Employees
![Page 9: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/9.jpg)
Data Aware Controls
Change the Text-boxes and OLE box to:
Control Name DataSource
DataField
Text1 txtLastName datEmployee LastName
Text2 txtFirstName datEmployee FirstName
Text3 txtID datEmployee EmployeeID
OLE1 olePhoto datEmployee Photo Size Mode1- Strech
![Page 10: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/10.jpg)
The New ADO Control
VB6 recommends using the ADO control instead of the older DAO-RDO.
ADO works well with local desktop DBMS software and remote database servers.
You need the Professional/Enterprise edition of VB.
![Page 11: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/11.jpg)
ADO Control & OLE DB
![Page 12: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/12.jpg)
Example1. ADO + JetEngine
Use the ADO control to show records in the MS-Access BIBLIO.MDB database.
Use the native “Jet-Engine” connection.
Data Aware Text Boxes
ADO Control
![Page 13: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/13.jpg)
Example1. ADO + JetEngine
Objects and Property Settings for the Authors Project.Object Property Setting
Form Caption Authors: ADO & JetEngineADODC1 Name
CaptionadoAuthorAuthors
Text1 NameDataSourceDataField
txtIDadoAuthorAu_ID
Text2 NameDataSourceDataField
txtNameadoAuthorAuthor
Text3 NameDataSourceDataField
txtYearBornadoAuthorYearBorn
![Page 14: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/14.jpg)
Example1. ADO + JetEngine
ConnectionString The ConnectionString can be set up at
design and run time. It tells VB how to get to the database. The Options are:
Jet Engine OLE DB (native to Microsoft Access)
ODBC (generic)
![Page 15: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/15.jpg)
Example1. ConnectionString
Adjust the property page of adoAuthor
Set CommadType: 2-adCmdTable
Click on ConnectionString button
![Page 16: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/16.jpg)
Example1. ‘Use Connection String’
Click on Option3 Push
BUILD
![Page 17: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/17.jpg)
Example1. Jet 3.51 Provider
Pick: JET 3.51 OLE DB Provider
Click on Next
![Page 18: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/18.jpg)
Example1. Database Name
Click on … button to locate file
Select Biblio.mdb
Test the connection, then push OK.
![Page 19: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/19.jpg)
Example1. RecordSource
Push … on the adoAuthorRecordSourceattribute
Choose the Authorstable
Apply, then OK
![Page 20: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/20.jpg)
Example1. Save & Run
Save all your files. Execute the application.
![Page 21: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/21.jpg)
Example2. Using ODBC
Open Data Base Connectivity (ODBC) is a software protocol to allow client applications -written in any language- to gain access to a database system.
![Page 22: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/22.jpg)
Example2. ODBC
Making ODBC connections in VB is a convenient practice because the steps involved are the same for all types of compliant database systems.
ODBCVB
Program
DatabasesMS-AccessMS-SQL ServerOracleSybaseIBM - DB2SAP. . .
ADO
![Page 23: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/23.jpg)
Example2. ODBC Data Source
Odbc Data SourceA named Open Database Connectivity (ODBC) resource that specifies the location, driver type, and other parameters
needed by an ODBC driver to access a database.
![Page 24: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/24.jpg)
Example2. Adding an ODBC Data Source
Bring the ODBC-Administrator from the Control Panel
Choose the32bit ODBCmanager
![Page 25: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/25.jpg)
Example2. Adding an ODBC Data Source
Click on the Add button
Select driver
![Page 26: Using the Data Access Controls: DAO & ADO Presented by Victor Matos.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a48a5d/html5/thumbnails/26.jpg)
Example2
1- Name the source: myBiblioLink2- Add a comment
3- Click Select
4- Locate the file5- Push OK