0 index
1 Data storage schemes
2 VB Data control
3 Advantages of Data control
4 Disadvantages of data control
5 Data Access Objects (DAO)
6 Typical recordset methods
7 SQL methods of the database object
8 Advantages of DAO
9 Disadvantages of DAO model
10 Enter Activex Data Objects / Controls
11 The ADO Data control
12 Setting up a connection:
13 Use the resulting database to set up a provider type
14 Setting the recordsource
15 Binding controls
16 Additional properties and events of ADO control:
17 Useful ADO methods (most are inherited from DAO)
18 Improvements in databound controls
19 Data Environments
20 Data Command Shortcuts!
21 Setting up a command to be a specific table
22 Setting up a command to be results of an SQL query

outline
created using slideshow.cgi by Andy Harris















IUPUI Computer Science: ADO Data
1. Data storage schemes
  • Sequential Access
  • Random Access
  • Indexed RA
  • RDBMS
  • OODBMS



































IUPUI Computer Science: ADO Data
2. VB Data control
  • A VB control
  • Connect to database
  • Attach to bound controls
  • Controlled entirely through VB
  • Divorced as much as possible from DB



































IUPUI Computer Science: ADO Data
3. Advantages of Data control
  • Very easy
  • simple control binding
  • variety of databases



































IUPUI Computer Science: ADO Data
4. Disadvantages of data control
  • Resource hog
  • Clumsy with multiple DBs
  • Limited SQL
  • No support for building databases or tables



































IUPUI Computer Science: ADO Data
5. Data Access Objects (DAO)
  • Object, not a component
  • OOP encapsulation of DB
  • How data controls worked under the hood
  • Recordset = collection of records
  • Record = collection of fields



































IUPUI Computer Science: ADO Data
6. Typical recordset methods
  • moveFirst, moveLast
  • moveNext, movePrevious
  • eof()
  • count()
  • findFirst



































IUPUI Computer Science: ADO Data
7. SQL methods of the database object
  • getRecordset(query)
  • returns a new recordset
  • execute()
  • Used for data definition, such as insert, update



































IUPUI Computer Science: ADO Data
8. Advantages of DAO
  • Much better flexibility
  • More efficient than data controls
  • Programmer has more control
  • Can use SQL to manage database



































IUPUI Computer Science: ADO Data
9. Disadvantages of DAO model
  • No binding to controls - must be done by hand
  • useful only for local databases of specified types
  • requires RDO for remote data access
  • ... and ODBC for ODBC connectivity



































IUPUI Computer Science: ADO Data
10. Enter Activex Data Objects / Controls
  • Attempt to unify ActiveX technology ...
  • with previous DB technologies
  • "unified model" of DB access
  • Both a set of controls AND DAO-Like objects
  • NOT directly compatible to DAO, DAO data controls
  • New features integrated into VB itself



































IUPUI Computer Science: ADO Data
11. The ADO Data control
  • NOT the same as the data control you've been using
  • Find it under the toolbox options
  • It will look something like "adodc1"
  • The properties will be much like the DAO DC
  • ..but not exactly.



































IUPUI Computer Science: ADO Data
12. Setting up a connection:
  • Click on elipsis (...) of connectionString property
  • connection types
    • data link
    • ODBC source
    • Connection string
  • For now, we'll choose connection string, and click on 'build'



































IUPUI Computer Science: ADO Data
13. Use the resulting database to set up a provider type
  • Then choose an existing database name (if it exists)
  • You can also use this dialog to set up a relationship with an existing
  • server (for example to connect to oracle db on ds9)
  • This dialog will be different for the different types of connections
  • There will be a 'test connection' button somewhere. You should run
  • the test.



































IUPUI Computer Science: ADO Data
14. Setting the recordsource
  • Once the connection is made, examine the recordsource property
  • Choose commandType (table, text, stored procedure)
  • If it's a table or stored procedure, choose it
  • If it's a text command, type in the SQL



































IUPUI Computer Science: ADO Data
15. Binding controls
  • Just like DAO -
  • Set each control's dataSource to the ADO control
  • Set the data Fields appropriately



































IUPUI Computer Science: ADO Data
16. Additional properties and events of ADO control:
  • BOFAction, EOFAction describe what to do when these events occur
  • willChange - a number of events useful for data validation
  • endOfRecordset - the user tried to go past recordset
  • error - some data error occurred



































IUPUI Computer Science: ADO Data
17. Useful ADO methods (most are inherited from DAO)
  • MoveFirst, MoveLast, MoveNext, MovePrevious
  • Update
  • Delete
  • Addnew



































IUPUI Computer Science: ADO Data
18. Improvements in databound controls
  • Data source isn't only ADODC!
  • Some controls can be directly bound
  • Databindings property
  • DataCombo, DataList
  • DataGrid
  • (note that DBx is usually NOT ADO-aware, and dataX usually is)



































IUPUI Computer Science: ADO Data
19. Data Environments
  • Way to manage data visually
  • Multiple data sources simultaneously possible
  • Data Environment -> connection object
  • connection object -> command
  • command ->recordset
  • All else is just like DAO



































IUPUI Computer Science: ADO Data
20. Data Command Shortcuts!
  • Once you have a data command specified,
  • Drag a table, procedure, or field to a form
  • A label and bound text box will automatically
  • be generated. (!)



































IUPUI Computer Science: ADO Data
21. Setting up a command to be a specific table
  • (presuming myCommand is existing command)
  • myCommand.commandType = adCmdTable
  • myCommand.commandText = "People"
  • set myRecordset = myCommand.execute



































IUPUI Computer Science: ADO Data
22. Setting up a command to be results of an SQL query
  • (presuming myCommand is existing command)
  • myCommand.commandType = adCmdText
  • myCommand.commandText = "Select LName, FName from people"
  • set myRecordset = myCommand.execute



































outline

Data storage schemes

VB Data control

Advantages of Data control

Disadvantages of data control

Data Access Objects (DAO)

Typical recordset methods

SQL methods of the database object

Advantages of DAO

Disadvantages of DAO model

Enter Activex Data Objects / Controls

The ADO Data control

Setting up a connection:

Use the resulting database to set up a provider type

Setting the recordsource

Binding controls

Additional properties and events of ADO control:

Useful ADO methods (most are inherited from DAO)

Improvements in databound controls

Data Environments

Data Command Shortcuts!

Setting up a command to be a specific table

Setting up a command to be results of an SQL query