microsoft access as an odbc client application a presentation for
DESCRIPTION
TRANSCRIPT
![Page 1: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/1.jpg)
Microsoft Access as an ODBC Client Application
A Presentation for the
Microsoft Access SIG
of the North Texas PC User Group
and the Metroplex Access Developers
by Larry Linson.
© Copyright 2000 by L.M. Linson, all rights reserved
![Page 2: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/2.jpg)
What is Access?
“A nice little desktop database” First popular Windows database For the novice For the power user For the developer A File Server database with Jet
![Page 3: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/3.jpg)
Access can build
A standalone database A multi-user database A client linked to ODBC databases A direct client to SQL Server A web interface to database
![Page 4: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/4.jpg)
Specifically
Microsoft Access 2, 97, 2000 .MDB or .MDE file format Jet database engine and Data Access
Objects (DAO) Tables LINKed via ODBC Driver to Server database (e.g. SQL Server)
![Page 5: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/5.jpg)
Specifically NOT
Access Data Project (ADP) Data Access Pages (DAP) ActiveX Data Objects (ADO) Other Web Interface (e.g., Front
Page) ODBCDirect
![Page 6: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/6.jpg)
How Many Users?
Multi-User– With everything wrong – 4, 5, or fewer
– With everything right – 90 to 150 ODBC Client
– Easily hundreds, limited only by
– Concurrent connections to server
– Essentially unlimited
![Page 7: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/7.jpg)
Multi-User Layout
Tables on Server– Available To All Users
On Users’ Workstations– Access (or Runtime)
– Application Part
– Fetch .DLLs, Objects Locally
![Page 8: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/8.jpg)
Client-Server Layout
Server Database Engine on Server– Extraction, manipulation done here
On Users’ Workstations– Access (or Runtime) and Jet database engine– Application
» Queries, Forms, Reports, Macros, Modules» Linked TableDefs and Local Tables
– ODBC Drivers, ODBC Data Source Information
![Page 9: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/9.jpg)
Jet is a File-Server
Retrieve, Extract, and Manipulate on User’s Workstation
Every I/O Done Across Network– That would normally be to local hard drive– Not whole database, nor necessarily whole table
– Just what Access finds necessary Index may be enough to find exact records
![Page 10: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/10.jpg)
Server Databases
Retrieval, extraction, and manipulation on the Server
Much less Network I/O– (Just) Requests from user to server
– (Just) Results from server to user
![Page 11: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/11.jpg)
Multi-user Layout . . .
DATAON
SERVER
PROCESSON USER
WORKSTATION
PROCESSON USER
WORKSTATION
. . . PROCESSON USER
WORKSTATION
![Page 12: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/12.jpg)
Client-Server Layout . . .
DATASTORED
INSERVER DB
CREATE REQUESTSEND / RECEIVE
DATA
PROCESSREQEST
IN SERVER DB
Request &Data
U I
![Page 13: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/13.jpg)
Comparison . . .
Server(Not Necessarily Windows)Windows
U I
U IU I
Data Only
Server Database with DataAccess, Jet, ODBC
Access, Jet
![Page 14: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/14.jpg)
What’s Different? . . .
Data in Server DB– Access User Interface to Server Databases– Performance – potentially better; possibly worse– Corruption – not really a factor
Multiple users of same data– Collisions (Add / Update) – Locking handled on server– Seeing Other Users Update – Refreshing– Updating Related Tables – Transactions handled jointly– Who Am I? – Identify Users to Access and to Server
![Page 15: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/15.jpg)
What’s Different? . . .
Retrieval, extraction, and manipulation on the Server
Fewer Problems – Network failures
– Power failures
– Individual User and Machine failures
Updating
![Page 16: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/16.jpg)
What’s Different? . . .
Access security
Server security – Tables on Server
» Accessing, manipulating, updating data
Security
Queries MacrosForms ModulesReports Local Tables
![Page 17: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/17.jpg)
What’s Different? . . .
Rules and triggers at the Server Don’t generate Access error
messages Your application has to have
– pre-validation and
– user notification
Data Validation
![Page 18: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/18.jpg)
What’s Different? . . .
As defined by Server database Server types may
– match directly to Access types
– not have Access counterpart » Text date fields
– not have all Access types» Counter, OLE, Memo
Data Types
![Page 19: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/19.jpg)
What’s Different? . . .
Defined by Server database,– Implemented on Server
Often enforced only by – Triggers
» Written manually
» Generated by Data Modeler
– Some (e.g., Microsoft SQL Server)» Automated, specified similar to Access
Referential Integrity
![Page 20: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/20.jpg)
What’s Different? . . .
Most servers do not permit– updating tables joined in SQL
ODBC workaround (sometimes) – Generate / send multiple updates
Pass-through Queries– Must adhere to server specifications
Updateable Queries/Views
![Page 21: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/21.jpg)
Performance Factors
Hardware Environment» More Memory» Faster Processors» Faster Hard Drives
Software Environment» Not Too Much Else Running
Network Environment» Faster is Better
Performance
Server is moreimportant thanuser’s machine!
Not as important
as in Multi-User
}
![Page 22: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/22.jpg)
More Factors . . .
Reduce Network Traffic – Application Design
Local tables (refresh from server)
Use Queries not Tables– Limit both Tables and Columns
– Database Implementation Queries, not DAO Code (When Feasible) Queries, not RecordsetClone.FindFirst
Performance
![Page 23: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/23.jpg)
More Factors . . .
Built-in performance factors – Re-planning query execution
Also called “compiling” “preparing” State of data is important
Stored procedures Like saved Queries in Access But with logic like code, too
Performance
![Page 24: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/24.jpg)
More Factors . . .
Tuning at the Server – Spread data over different disks– Monitor Performance
» Analyze» Add, remove, modify indexes
– Database Administration» More TLC» That’s why there are DBA’s
Performance
![Page 25: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/25.jpg)
But . . .
Jet can be smart – Return only part of large recordset– Create separate query for FindFirst
It may “save us from ourselves”
Performance
![Page 26: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/26.jpg)
Views Restrict user access
– Only the specified columns– Only the specified rows
Like Access’ “Saved Queries” Appear as Tables to Jet / Access Also assist performance
– Force joins and selection at server
Data Integrity
![Page 27: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/27.jpg)
Record Locking . . . Done “co-operatively” in C/S
– Jet passes the request– Locking actually done by the server– Considerations same as Multi-User
» Except: you may lock out more users» May be a smaller time window for some
So, let’s just “fly through” – the repeated slides
Data Integrity
![Page 28: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/28.jpg)
Record Locking . . . In Bound Forms
– No Locks (aka Optimistic Locking)» Only in the instant the record is saved
– Edited Record (aka Pessimistic Locking) » As soon as user begins to edit
– All Records» All records in the entire recordset» Batch Updates» Administrative Maintenance
Data Integrity
![Page 29: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/29.jpg)
Record Locking . . . Possibilities by Object
– All Three Options» Table datasheets; Select, Crosstab, Union Query, Forms, OpenRecordset
– Lock Edited Record or All Records » Update, Delete, Make-Table, Append
– Lock All Records » Data Definition Queries
– No Locks or Lock All Records» Reports
Data Integrity
![Page 30: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/30.jpg)
Record Locking . . .
Default Record Locking Option– Established by menu Tools | Options
Applies to All, Except– Data Definition Queries – All Records– Open Recordset – Edited Record
Data Integrity
![Page 31: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/31.jpg)
Record Locking . . . OpenRecordset
– dbDenyRead or dbDenyWrite– Overrides .LockEdits property– Native Access Tables Only
.LockEdits Property– True = Edited Record (the default)– False = No Locks
Data Integrity
![Page 32: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/32.jpg)
Record Locking . . . Advantages of Pessimistic Locking
– Simple to Develop, Prevents Overwriting
Disadvantages of Pessimistic– Lock Multiple Records, Less Concurrency
Advantages of Optimistic Locking– Simple to Use, Better Concurrency, Less Lockout
Disadvantages of Optimistic– Can be Confusing to User, Allows Overwriting
Data Integrity
![Page 33: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/33.jpg)
Record Locking
Generally, use Optimistic– Minimize User Lockout
Or, Mixed, by Specific Object– Most Optimistic, but– Critical Information, Pessimistic
» Example: Quantity on Hand in Inventory
Data Integrity
![Page 34: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/34.jpg)
Transactions . . .
Changes in a batch All Succeed or All Fail Same or Related Tables
– Allocate Stock to Order, Deduct Stock on Hand – Credit New Account and Debit Old Account
Data Integrity
![Page 35: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/35.jpg)
Transactions . . .
Server can resolve problems– From failure occurring any time– Full audit trail– Hot backup – second copy of data
No– Orphan locks in .LDB– Data loss, lockout, corruption due to
» Errors that occur while committing
Data Integrity
![Page 36: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/36.jpg)
Transactions
Consider client-server if– Processing funds transactions– Performing critical inventory updates– Etc.– Regardless of other considerations
» Performance
» Number of users
Data Integrity
![Page 37: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/37.jpg)
Identifying Users Typically secure the database
– Everyone Logs In
Viewing and Reporting– MSLDBUSR.DLL by Microsoft– Unsupported
Server Security– Log in to connect and link
Miscellaneous
![Page 38: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/38.jpg)
Some Cautions . . . Jet may lose track of record
– When using server equivalent of AutoNumber– Data entry works fine– When record saved, all show “#Deleted”
Countermeasure– Table of tables and next id number– Stored procedure to return next id– Never use “data entry”, always editing
Miscellaneous
![Page 39: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/39.jpg)
Cautions . . . “Complex” queries
– More than two joins – Jet sometimes decides– Brings back a flood of data
Countermeasure– More than two joins, performance slow– Consider creating a view– View appears as Table to Jet– Forces joins and extraction on server
Miscellaneous
![Page 40: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/40.jpg)
Cautions . . . “Complex” queries (alternative)
– More than two joins – Jet sometimes decides– Brings back a flood of data
Countermeasure– Create a passthrough Query– Tells Jet, “Hands off!”– Forces joins and extraction on server
Miscellaneous
![Page 41: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/41.jpg)
Cautions . . . “Order by” not a key, not indexed
– “Order By field must be in Select Clause”– Message is erroneous
Countermeasure– May have to make it a key or index– May be able to use a passthrough Query
Miscellaneous
![Page 42: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/42.jpg)
Cautions . . . Some joins won’t work in Access
Query
Miscellaneous
tabid
tabname
colid
tabid
colname
TableName
ColumnName
.
.
.
•continuedServer Tables
Access Table
![Page 43: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/43.jpg)
Cautions . . . Countermeasure – “intermediary”
Miscellaneous
tabid
tabname
colid
tabid
colname
tabname
colname
Server Tables Access Tables
tabname
colname
TableName
ColumnName
Query
![Page 44: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/44.jpg)
Resources . . .
Access 97 Developer’s Handbook by Getz, Litwin, Gilbert published by SYBEX ISBN: 0 - 7821 - 1941 - 7 Chap 15 – Developing Client-Server
Applications
![Page 45: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/45.jpg)
Resources . . .
Access 2000 Developer’s Handbook, Volume 2: Enterprise Edition
by Getz, Litwin, Gilbert published by SYBEX ISBN: 0 - 7821 - 2372 - 4 Chap 3 – Developing Client-Server
Applications (also other chapters this volume)
![Page 46: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/46.jpg)
Resources . . .
Building Applications with Microsoft Access 97
Manual, comes with Office Developer or the MSDN Library
publisher: Microsoft Chapter 10 – Creating Multi-User
Databases
![Page 47: Microsoft Access as an ODBC Client Application A Presentation for](https://reader035.vdocuments.site/reader035/viewer/2022062615/54856138b47959f10c8b4e4d/html5/thumbnails/47.jpg)
Resources
Microsoft Office Visual Basic Programmer’s Guide
Manual, comes with Office 2000 Developer or the MSDN Library
publisher: Microsoft Chapter 16 –Multi-User Database
Solutions