Unit 5: Introduction to BCB Database Architecture - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Unit 5: Introduction to BCB Database Architecture

Description:

Support for creating advanced database applications. ... E.g., Oracle and Sybase. Provides transparent data sharing between applications ... – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 19
Provided by: conest
Category:

less

Transcript and Presenter's Notes

Title: Unit 5: Introduction to BCB Database Architecture


1
Unit 5 Introduction to BCB Database Architecture
  • Borland C Builder DB Components
  • Overview
  • Simple Database Demo
  • BCB Database Tools/ Components
  • SQL Explorer
  • ADO, Data Access and Data Controls
  • TDataSet Key Functions

2
Benefits of Using BCB
  • Support for creating advanced database
    applications.
  • Has built-in tools to connect to different DB
    vendors
  • E.g., Oracle and Sybase
  • Provides transparent data sharing between
    applications

3
Other BCB Features
  • Easy to use (controls drag and drop)
  • Many features
  • TDataSource component for maintainability
  • Data Controls (TDBGrid, TDBEdit, etc.)
  • Connection to Data
  • Borland Database Engine (BDE)
  • ActiveX Database Object (ADO)

4
BCB Database Architecture
  • BCB DB Application can be organized as follows

BDE, ADO, etc.
DataModule.cpp
DataSet
DataSource
DB
Form
Connection to Data
Table, Query, StoredProc
5
Simple Demo Using ADO
  • Dbdemo.mdb has a Customer table

DataModule.cpp
Dbdemo.mdb
TADO Connection
TDataSource
TADOTable
MS Access
OLE DB ODBC
Form
DS name dbdemo
conDbDemo
tblCustomer
dsCustomer
6
Simple Database Demo (1)
  • Download dbdemo.mdb (web page)
  • Setup ODBC Data Source
  • Database Explore
  • Object ODBC Admin
  • System DSN page Click Add
  • Create new DS Select MS Access Driver
  • DS Name dbdemo
  • Select dbdemo.mdb
  • Click OK

7
Simple Database Demo (2)
  • File New Application
  • File New DataModule
  • Change Name to dmBCBdemo
  • Add TADOConnection (from ADO page)
  • Change Name to conDBDemo
  • Setup ConnectionString property
  • Use DS Name dbdemo
  • Click Test Connection (must succeed to continue)
  • Set LoginPrompt to false
  • Set Connected to True

8
Simple Database Demo (3)
  • Add TADOTable (from ADO page)
  • Change Name to tblCustomer
  • Change Connection to conDBDemo
  • Change TableName to Customer
  • Change Active to true
  • Add TDataSource (from Data Access page)
  • Change Name to dsCustomer
  • Change DataSet to tblCustomer
  • Change AutoEdit to false (i.e., read-only)

9
Simple Database Demo (4)
  • Result of data module for simple demo

10
Simple Database Demo (5)
  • Change Form1s Name to frmMain
  • Save All frmMain to frmMainC.cpp, dmBCBdemo to
    dmBCBdemoC.cpp, and project as Simple.bpr
  • Add TDBGrid to frmMain (from Data Controls page)
  • Change Name to dbgCustomer
  • Change Align to alClient
  • File Include Unit Hdr -gt dmBCBdemoC
  • Change DataSource to dmBCBdemo-gtdsCustomer
  • Check if dmBCBdemo unit is auto-created (under
    Project Options)
  • Run the project!

11
Simple Database
  • Result of TDBGrid data control linked to
    dsCustomer

Note If you encounter EvariantTypeCastError
'Could Not Convert Variant of Type (Null) into
Type (String), add ALL persistent fields to your
tblCustomer using Object TreeView.
12
References
  • ADOSetup hand-out
  • BCB ADO Examples (shape and briefcase)
  • For further reading (optional)
  • Intro. to Data Components (External Link)
  • BCB Database Tutorial

13
Data Control DBEdit
  • Adding DBEdit controls using SQL Explorer

14
Data Control DBNavigator
  • Add DBNavigator to form
  • Change DataSource to dsCustomer

15
Data Navigator Component
  • Provides a set of buttons for performing common
    database operations
  • Bound to a DataSource (e.g., dsCustomer)

16
TDataSet Key Functions
  • TADOTable inherits these functions from TDataSet
  • Open()
  • Close()
  • Edit()
  • Post()
  • Cancel()

17
Demo Add a Close Button
  • Open the Simple Demo
  • Add a command button named Close
  • Write an event handler to close the Customer
    table
  • Note TDataSource not needed for accessing
    TADOTable functions

void __fastcall TfrmMaincmdCloseClick(TObject
Sender) dmBCBdemo-gttblCustomer-gtClose()
18
Assignment 2
  • Window Controls
  • Command Button Visible Hide()/Show()
  • Key TDataSet functions
  • Open(), Close()
  • Edit(), Post()
  • TPageControl, TPanel
  • Read Assignment 2 fore more info.
Write a Comment
User Comments (0)
About PowerShow.com