Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
•
Windows Multi-DBMS
Programming Using C++, Visual Basic®, ODBC, OLE2,
and Tools for DBMS Projects
Ken North
John Wiley & Sons, Inc. New York • Chichester • Brisbane • Toronto • Singapore
: . . . . • - .
Contents
Preface
Chapter 1 Overview and Introduction The Changing Face of Development
Overview Required Hardware and Software
XXV
1
2 2 3
Chapter 2 Windows Software Development: Concepts and Issues
Terms and Concepts Windows Features and Database Applications Processes, Tasks, and Threads Multitasking Protected Addresses and Safe Multitasking Threads: NetWare and Win32 Scheduling Windows Programming Static and Dynamic Linking Dynamic Link Libraries INI Files Resources and Help Files Dialog Boxes Custom Controls Notation
Windows Developer's Notebook Baselines Version Control Common Development Steps
5 7 7 8 8 9 9
10 11 12 12 12 13 14 14 15 15 16 16
VH
viii Contents
Pseudocode 17 Debugging 17 Visual Programming 19 Formal Development Methods 19 Crafting Code for Windows 20
GUI Design Considerations and Database Applications 20
Chapter 3 Database Applications: Concepts and Issues 22 Building Database Applications 22 Database Architectures 23
DBMS Evolution 23 ISAM 24 Network and Hierarchical Databases 24 SQL and Relational Databases 25 Desktop, File Server, and Client-Server 29
Terms and Concepts 30 SQL Concepts 38
Database Design 39 Network Database Design 40 Relational Database Design 40 Query Optimization 45 Issues 48
Sample Database and Applications 49 Info Enterprises 49 Sample Applications 50
Road Map for Database Developers 55 Tools for Developing Database Front Ends and Client Applications 56
Chapter 4 Solutions for Multidatabase Programming 57 Terms and Concepts Gateways and Routers Embedded SQL APIs and CLIs
Standard Database APIs: A Historical Perspective and Future Open Database Connectivity (ODBC) INTERSOLV/Q+E Database Library
57 58 59 59 60 61 63
Contents ix
•
EDA/CLI Oracle Glue ODBC Drivers
Components and Custom Controls Using Objects to Access Data
Data Access Objects Interoperable Objects
Late Binding Issues Affecting Interoperability Distributed Objects and Remote Data Access Formulating a Database Development Strategy
Chapter 5 Servers and Database Engines
•
•
SQL Server for Windows NT SQL Server Tools Transact-SQL Stored Procedures, Triggers, and Rules Preparing for ODBC INI Files Creating Databases and Tables
Watcom SQL Locking and Isolation Levels Administering Watcom SQL ODBC Setup Programming Notes
Quadbase-SQL VBQUERY Quadbase-SQL XB/Server SQL Scripts Quadbase SQL Command Details
Microrim R:BASE and R:BASE SQL Engine R.-BASE Functions
Raima Database Server Database Administration Database Navigation RDSSQL ODBC and Raima SQL Functions
64 65 65 66 66 67 67 68 69 69 70
71 72 74 76 78 80 81 84 91 93 93 98 98
105 106 107 108 111 111 112 115 115 115 120 120
x Contents
Oprifm'zaft'o« Extension Module Programming
Gupta SQLBase Transaction Logs and History Files Configuration File SQLBase Administration and SQLTalk Data Organization Networking, SQLGateway, and SQLRouter SQLBase SQL Notes Optimization, Query Plans, and Indexes Stored Procedures, Triggers, and Events С Programming API Example Database
Information Builder's EDA / SQL Programming EDA/SQL
Coromandel Integra VDB Visual Data Manager Visual Query Builder Trigger Definition Custom Controls
Page Ahead's Simba and ODBC Desktop Databases Desktop Driver Notes
Conclusion
Chapter 6 Using ODBC Г1*" v wein^ wwww
Architecture Components
Functions and Features Conformance Levels Relationship to the Windows API Driver Manager Processing Data Types
Installation Setup ODBC SDK Files Used with ODBC
122 123 123 124 125 127 128 130 130 131 132 133 133 141 141 143 143 146 146 147 155 156 159
160 161 163 166 166 166 171 172 174 174 174 175
Contents xi
ODBC Administrator 176 Tracing 177 Configuring Data Sources 178
ODBC SQL 184 SQL Extensions 185 Qualifiers, Owners, and Procedures I9l
ODBC Programming 192 Handles 192 Options That Govern Behavior 192 Connections 194 Metadata, Catalog Information 196 Statements 197 Cursor Operations 200 Results Processing 201 Termination 204 Typical Processing Sequence 205 Referential Integrity 206 Asynchronous Processing 206 Transaction Processing and Concurrency 206 Cursor Library 208 Translation Libraries 211
Interoperable ODBC Applications 211 Л Fundamental Concept 211 Issues Affecting Interoperability 212 Interrogating for Available Features 217 Interrogating for Available Functions 217 Creating Databases and Tables 219 Interrogating for Available Data Types 219
Developer Guidelines 220 Linker Errors with C++ 221 Debugging and Testing 221 Development and Optimization Hints 223 ODBC or Access Engine ? 224 ODBC as a Tool 225
Why ODBC? 225 Supplemental Information 226
0 Ш С Benchmark Kit 226
xii Contents
Chapter 7 Using INTERSOLV QELIB 228 Installation and Features 228
Multiple Access to Data Sources 229 QELIB Data Types 230 Required ODBC Functions 231 Dates 233 Format Strings 233 Joins 233
Functions 233 Connections and Statements 234 Parameter Queries 235 Transactions 236 Retrieving Data 237 Fetching and Caching Result Sets 238 Column Values Retrieval 239 Metadata and Catalog Functions 240 Column Functions 240 Processing Memo and BLOB Data 241 Modifying Records 241 Уег^гои Information and Initialization 243 £rror Handling and Debugging 243 Query Tools 244
Para'/ig 5ßL 246 ODBC Handle Conversion 246
Date-Time Functions 247
Data Conversion 247 Language Considerations 248 Programming Notes 249
0£L/S and ODBC 249
Portable SQL Functions for QELIB 249
Example Programs 250 T • i /-i о с т Typical Query 252 Column Description Information 252
Chapter 8 Data Access and Data Presentation Tools 258 Gupta Quest 259
QuestWindow 260
Contents xiii
Queries
Aggregate Functions
Nonaggregate Functions
Microsoft Excel
Setup
Accessing Data
ODBC Extensions
Executing Queries
Using Microsoft Query
Dynamic Data Exchange (DDE)
Microsoft Word for Windows Setup
Accessing Databases
Executing a Query with Word
Using Attached ODBC Tables and Access
Word Developer's Kit and WordBasic
Using the ODBC Extensions
Example Report Macro
Mail Merge
InfoPublisher
Tables
Queries
InfoPublisher and Databases
Crystal Reports for Windows
Report Language Functions _ Pro Edition Indexes Report Layout Mode
Print Engine Programming
Crystal Reports VBX Properties
Example Reports
Dynamic Queries
Form Designer
Links to Other Applications
Lotus 1-2-3 Lotus DataLens
DataLens Driver Notes
260
ZOl
271
272 272
272 274 275
277
279 279 280
280
280
283 284 285
287
288
288 289 290
290
291 292
Zyi
293 298
301
305
305
305 306
307
309 310
xiv Contents
Chapter 9 Rules, Facts, and Objects 312 Asymetrix InfoModeler 312
Views and Modeling a Database 313 FORML 313 Repository, Versions, and Object Reuse 314 Predicates 314 Fact Compiler, Diagrammer, and Table Browser 315 Constraints 316 Mandatory Roles 316 Cardinality 317 Sample Populations 317 Quick Tour 317 Verbalizer and Fact Assistant 319 Driver Notes 320 Example Model 320 InfoEnterprise Tables 321
Using Rules and Databases 322 Rule-based Applications 323
Information Builders' LEVEL 5 OBJECT 323 Actions and RuleTalk 324 Knowledge Base and Inference Engine 325 Editors 325 Actions 327 Using Databases 328
Object Orientation and Object-Oriented Programming 330 Messages, Late Binding, Virtual Methods 332 Data Hiding 333 Object Limitations 335 Conclusion 336
Chapter 10 Tools for Software Developers 337 Developer Tool Roadmap 338
ProtoGen+ Workbench 339 ViewPaint 339 WinControl Library 341 ProtoView Screen Manager 341
Contents xv
• SQLView Field Controls Methods SQLView API Error Handling Visual Development Example
Proto View's ProtoGen+ Application Regeneration Steps to Creating a User Interface
Proto View DataTable Setup
Graphics Server SDK and ChartBuilder Charting Features
Oracle Glue for Windows Containers Glue Architecture and API Generic Glue DLL SQL Glue Language Palmtop Glue and Wizards Visual Basic Glue Programming WizLink Sample Application
Magic Fields Magic Fields API
WindowsMAKER Pro Visual Screen Designer Extended Functionality Modules Quick Look
Visual AppBuilder Visual Programming Layout Window Database ALM and the Database Object Browser Object Table Object Other Database ALM Objects Using AppBuilder Client-Server ALMs Client-Server Example Program
•
347 348 348
353 353
355 355 355 357 358
358 359 360 361 361 362 363 365 367 368
373 374
376 376 376 377
379 379 380 382 382 383 •JO.J
389 389
xvi Contents
Chapter 11 Client-Server Tool Suites 391 ObjectView 391
Database Interface 393
Visual SQL and Personal SQL 395 Workgroup Library 396
Other Features 397 Command Files 398
Development Cycle 399 Developing with ObjectView 399
ObjectView Scripts 400 Panel Events 401 ObjectView and the TODO List Example Application 402
Gupta SQLWindows 403
Objects and Data Types 404
Messages 405 SQL Programming 406 ReportWindows 408 EditWindows 409
TeamWindows 409 Data Dictionary 411
Creating a PERINFO Data Dictionary Using TeamWindows 412 Template Library 413
QuestWindow Example 413 SQLWindows 5.0 416
Powersoft PowerBuilder 419 Painters 420 PowerScript Programming 425 Libraries, Executables, and INI Files 429 ODBC Interface 430
PowerBuilder and OLE 432 Extending PowerBuilder *? 432 Advanced Developer Toolkit 433 Required Resources 433 Report Generation and PowerViewer 434 Example SQL Scripts 434 Creating a PERSINFO ToDo Example Browser 437
Contents xvii
Chapter 12 Client or Client-Server (FoxPro and Access) 442 Microsoft FoxPro for Windows 442
Architecture 443 Screen Builder 443 Menu Builder and Report Writer 443
RQBE 444
Using Index Files 445 Creating FoxPro Tables for the Example Application 445 FoxApp and the Sample Application 453
FoxPro Connectivity Kit 455 FPSQL Programming 457 Getting ODBC Data Source Table Information 459 Executing Remote Queries Using ODBC 460
FoxPro Connectivity Demo Executive Information System 462
Microsoft Access 463
Database Organization and Permissions 464
Tables and Views 465 Referential Integrity 467
Queries 468 Forms 471 Reports 473 Customizing Access Applications 473
Macros 473
Events 473 DDE and OLE 476 SQL and Data Types 476
Btrieve Files 479 Mapping Data Types 480
Using Access and the Access Engine with ODBC 481
Cursor Model 482 Connections and Statements 482
Cursor Commit Behavior 482 Dynasets and Snapshots 483 Level 1 ODBC and Unique Indexes 484
Exporting Data 484 SQL Pass-through 484
xviii Contents
Local Processing and Heterogeneous Joins 485 Server Data Modification 486 Configuration Information 486
Frequently Asked Questions 487
Programming with Data Access Objects in Access and Visual Basic 487 DAO Programming Notes 489 Collection Methods 491 DBEngine Object 492 Database Object 492 Container Object 493 Document Object 493 Relation Object 494 Group Object 494 User Object 494 Workspace Object 495 Field Object 495 Index Object 496 TablesDefs and Database Structure Information 497 QueryDefs 498 Parameter Object 498 Recordsets 499 Property Object 502 Considerations for the Future 509 Fi'eW Properties 509 Indexes 509 Example Access Database 510
Performance Hints for Using Access in Client-Server Applications 511 Local Tables 512 Forms 512 Connections 512 Timestamps 513 Transactions 513 Indexes 513 Stored Procedures 513 ^ , C I O
Queries 513 Locks 513
Contents
Chapter 13 Database Programming with Visual Basic Choice of Techniques
Programming with the Data Control
Data Control Example
Calling ODBC API Functions
Developer Notes
Object Layer vs. API
OLE Automation Client
Stored Procedures
Multimedia and the Media Control Interface (MCI)
Optimizing VB
E-mail, Messaging, and MAPI
Electronics Forms Designer
Registrant Sample
Database Updates with MEF
Distributed Report Applications
Visual Basic Add-ons
Bound Controls
Custom Controls for Visual Basic
INTERSOLV MultiLink/VB
Custom Controls
Programming with MultiLinWVB
Visual Basic for Applications
Conclusion
xix
514 520
522 523
525 534
535
^ 535 538
539
543
543
547 547
548
549
549 550
553 554
554
561
563
Chapter 14 Database Programming with C++ Infrastructure
Component Development (DLLs, VBXs, OCXs)
Windows 95 SDK
Client-Server Tool Suites
Libraries
Wizards and Experts
Message and Event Handling
Serializable, Streamable Objects
564 564
567
567
J O o
4A.Q JO»
568
570
xx Contents
Record Handling with Record Field Exchange and Transfer Buffers
Resource Editors
Document/View Architecture
Exception Handling and Templates
Browsers
Borland C++
Class Libraries
Resource Workshop
Winsight and WinSpector
IDE, AppExpert, and Class Expert
IDE Debugging, Turbo Debugger
Streams
ObjectWindows Library (OWL)
ObjectWindows 2.0 Classes
Database Development with OWL
Borland Database Engine
Microsoft Visual C++
Visual Workbench
AppWizard, ClassWizard
Microsoft Foundation Classes (MFC)
MFC Class Hierarchy
AppStudio
Integrated Debugging and Codeview
Exception Handling and Templates
Multithreading Routines
Version Control with VER.DLL
Developing ODBC Programs
Developing SQL Classes
Design Issues
Polymorphism
Caveats
C++ and SQL Objects
Developing QELIB Classes
Developing ODBC Classes
Building the Applications
Program Example: Metadata with ODBCDict and QEStruct
QEStruct
570
571
571
572
572
572
572 574
574 574
576 577
578
579
583 584
584
586 586 587
588
591 592
593 594 594
595
595
596 596 597
598 598
600 603 603
605
Contents xxi
Back-end Interrogation 607 Guidelines for Extensions 608
Chapter 15 Solutions for C++ Database Programming 610 Borland C++ and Visual Solutions Pack
Date Formats
Database Operations
Triggers
Modifying the To Do Example
Using Integra VDB and Visual C+ +
MFC Database Classes
Database Class
Recordset Class
Record View Class
Database Exceptions Class
BLOBs (Long Binary Class)
Data Exchange Class
ODBC Conformance Issues
Cursor Library * MFC Components
AppWizard Database Support Options
Example Application
Using a Single Database Object with Multiple Recordsets
OLE and OCXs
OLE Control Developer's Kit
Bound Controls
Why Use the CDK?
Chapter 16 Programming with OLE 2.0 Overview
OLE versus "Traditional" Techniques
Standards for Interoperable Objects
OLE 2.0 Architecture
Terms, Concepts, and Features
Component Object Model
User Interface Issues
610
611 614 618 618 621
624 627 628 632
633 634
634 635 635 636
636 637
651
651 652 / «
655
657 657
658
658
659
660
661 661
xxii Contents
Linking and Monikers
Compound Documents and Embedded Objects
Embedding and Linking Issues
Object Interfaces
Interface Inheritance
Unique Identifiers and the Registration Database
Marshaling, Concurrency, and Notifications
Data Objects and Uniform Data Transfer
Structured Storage and Streams
Clipboard and Drag and Drop
In-place Activation
OLE Automation
OLE Interfaces and Functions
Debugging
DispTest
MFC OLE 2 Classes
OLE Classes
OLE 2 Features Not in MFC 2.5
Updating the Registration Database
Automation Server Example Using MFC
Examining the Application Class
Dispatch Interface
Examining the Document Class
Getting, Setting, and Exposing Properties
Exposing Methods
Dispatch Map
Automation Client Example
Visual Basic for Applications
661 662 662
663
663 663 664
665 666
666 666 667
667
673 673
674
674
679
679 679 682
683
683
689 690 692
692 692
Chapter 17 Lagniappe 694 Sharp Wizard
Oracle Palmtop Glue
Monitoring and Tracing Tools
odbc Inspector
SQL Inspector
Dr. DeeBee Tools
DataSync
- J * 694
696
696
697
699
699
703
Contents xxiii
Rules and Operation Subset Definition
Access Upsizing Tools Permissions
RoboHELP Query Analyzer SQL Code Profiler
Workgroup Applications Schedule+ Lotus Notes Connectivity
УВЯШ Using Voice and Sound in Database Applications
Attaching Sounds to Alerts Voice Recognition Windows Sound System
Video for Windows MCI Command Messages for A VI Data MCI Control
Computer Eyes
703 704 704 706 706 707 708 709 710 710 711 711 711 711 712 718 718 719 720
Appendix A Windows Multi-DBMS Programming Companion Software 721
Companion CD-ROM 721 IMPORTANT NOTICE 721 CD-ROM Contents 722 SQL Scripts for the Sample Databases 723
ScreenCam Movies 725 ODINFO 726
Windows Software 726 Code Manager and Search Professional 726 Crystal Reports for Windows 726 ObjectView Limited Edition 727 Microsoft ODBC Desktop Drivers 727 ODBSEEME 727 Q+E Database Library and MultiLink/VB 727 Quadbase-SQL 3.0a 727
xxiv Contents
Microsoft Video for Windows Runtime System 728 Watcom SQL 3.2 Runtime System for Windows 728 SDP Technologies S-Designor Evaluation Kit 728
Appendix В Sample ODBC Initialization (ODBC.INI)
File for a Client PC 729
Appendix С Sources for ODBC Applications and Tools 737
Appendix D ODBC Driver Contact Information 742
Index 749
';; • • • • ' , ' • , .;:
fr