CS 395 Database Practicum C' Shilepsky - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

CS 395 Database Practicum C' Shilepsky

Description:

Actually maps the db to VB controls on a form ... Start a blank project. Under Project/Add Form select VB Data Form Wizard. No profile ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 13
Provided by: Science82
Category:

less

Transcript and Presenter's Notes

Title: CS 395 Database Practicum C' Shilepsky


1
CS 395 Database PracticumC. Shilepsky
  • Class 5, March 5, 2001

2
Files for Class 5
  • TestTimer.vbp
  • Magnet.mdb (Access file)
  • Magnet.vbp (VB project)
  • bank.mdb for homework

3
Adding a Timer
  • Control the clock
  • Properties
  • Interval (in milliseconds)
  • Enabled (whether it is operating
  • Methods
  • Timer (action to occur each interval)

4
Database Access from VB
  • VB can connect to a database.
  • The default database is Access
  • VB contains the Jet database engine and doesnt
    need Access to create and operate on .mdb
    (Access) files.
  • Connection can be through a data control or by
    direct coding.

5
Example (Magnet)
  • Database Magnet.mdb.
  • Open in Access
  • View the table tblOrderMaster
  • Fields fldOrderID, fldCustomerID, fldOrderDate,
    fldOrderCost, fld OrderSales
  • VB Project Magnet.vbp
  • One form frmOrder
  • The bar at the bottom (data control) allows you
    to navigate through Magnet.mdb

6
Data Control
(on the form)
(the database)
(on the form)
7
Data Control
  • Enables user to interface with database functions
    (to retrieve, update, navigate).
  • Actually maps the db to VB controls on a form
  • Data control is not visible, rather a conduit to
    the particular db.
  • Runtime the data control establishes the
    connection to the database and mediates
    interactions.

8
Bound Controls
  • On a form
  • Visible
  • These display a field from the current db record
    or query.
  • They are bound via the data control.

9
Data Control for Magnet
  • datOrderMaster
  • Properties
  • Caption--the name in the control
  • Connect--the type of database (Access)
  • DataBaseName--Magnet.mdb (you may need to update
    this for your location)
  • RecordSource--the Access table that provides data
    to the VB form

10
Bound Controls for Magnet
  • Data control datOrderMaster is set up the link to
    the Access database
  • txtOrderID,..,txtOrderCost now need to be bound
    to data fields in Magnet.mdb
  • txtOrderID Properties
  • DataSource (the control) datOrderMaster
  • DataField (the element in the control)
    fldOrderID
  • Note txtOrderProfit not bound to anything
  • Changes in Access database reflected on the VB
    form and conversely

11
Using the VB Data Form Wizard
  • The Data Form Wizard automates building a simple
    form that connects to a database.
  • How
  • Start a blank project
  • Under Project/Add Form select VB Data Form Wizard
  • No profile
  • Access database. Magnet.mdb
  • Single Record
  • Record Source tblOrderMaster
  • Challenge what does the code mean?

12
Homework
  • Build a front-end viewer for bank.db
  • Include a data control and bound control for each
    field in the branch table.
  • Note, the naming of tables and fields in bank.mdb
    do not match VB conventions (tblX, fldX)
  • Do the same using the Data Wizard. We will go
    over its features and the code next class.
  • Reference Rahmel, Teach Yourself Database
    Programming
  • with VB 6 in 24 Hours, p.11-37.
Write a Comment
User Comments (0)
About PowerShow.com