![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Advanced Visual Basic Techniques
The user should then enter a new password twice. The password is entered twice to guard against typing mistakes. If the same value is entered in both new password fields, the user probably did not make any typing errors.
Key TechniquesPeopleWatcher demonstrates many important Visual Basic programming techniques. The following list describes these techniques briefly. The rest of the chapter explains them in detail.
Understanding DatabasesThere are many different kinds of databases. Visual Basics native database format is the same as the format Microsoft Access uses. Because it is designed specifically to work with Access databases, Visual Basic provides the best performance with them. Visual Basic can also manipulate data in many other database formats, including Btrieve, dBASE, Microsoft FoxPro, and Paradox. This chapter and those that follow deal only with Access databases. For information on how to use other kinds of databases, search the Visual Basic help for Accessing External Databases and consult the other databases documentation. The following section provides a brief overview of database engines. It describes compatibility issues involving the engines that come with different versions of Visual Basic. The next section describes the Data Manager, a Visual Basic add-in that can be used to create and maintain Access databases. If you already understand Access databases thoroughly, you may want to skim these sections or skip directly to the following section, Using the Data Control. Database EnginesA database engine is the software that provides database functionality. It provides support routines with which an application can manipulate data stored in database files. Visual Basic uses the Microsoft Jet database engine; Microsoft Access uses this engine as well. Visual Basic 4 and Visual Basic 5 come with two versions of the Jet engine and can work with databases of two major types. Version 2 databases are for use with 16-bit applications. Version 3 databases are for use with 32-bit applications. The features provided by both of these versions are similar so a developer rarely needs to worry about the difference. One place the differences are important, however, is in loading database files. The Jet engines provide backward compatibility. That means the version 3 engine can read a data file written by a version 2 engine. The reverse is not true. A version 2 engine cannot read a version 3 database. If a version 2 engine attempts to load a version 3 database, it presents a message similar to the following: Run-time error 3049: Cant open database C:\People30.MDB. It may not be a database, or the file may be corrupt. The database files on the compact disk are all Jet version 2.5 databases so they can be opened by either 16-bit or 32-bit applications. The example programs should run on either platform. Before an application can use data access objects to manipulate data, the application needs to give Visual Basic a reference to the object library it will use. The References command in the Tools menu makes the References dialog box appear. Checking the box next to Microsoft DAO 2.5 Object Library allows the application to use the 16-bit object library. Checking the box next to Microsoft DAO 3.0 Object Library allows the program to use the 32-bit version. The 16-bit version of Visual Basic 4 lists only the 16-bit object library because it cannot use the 32-bit version. The Data ManagerThe Visual Basic 4 Add-Ins menu comes with the Data Manager application already installed. Visual Basic 5 includes a Visual Data Manager add-in. Both of these programs can be used to create and manage databases. Their functions are similar, but their details differ so they are not described here. Both are fairly easy to use and both provide online help. Just as there are multiple versions of the Jet database engine, there are multiple versions of the Data Manager. The Add-Ins menu in the 16-bit version of Visual Basic 4 starts the 16-bit version of the Data Manager. This version creates new databases using the Jet 2.5 engine, and it cannot open Jet version 3.0 databases. The Add-Ins menu in the 32-bit version of Visual Basic 4 starts the 32-bit version of the Data Manager. This version creates new databases using the Jet 3.0 engine. It can open both version 2.5 and version 3.0 databases. Using the Data ControlVisual Basic provides two main methods for interacting with databases: the data control and data access objects (DAO). The data control allows a developer to build simple database applications with little or no programming. While the data control is simple, it is also fairly limited. Data access objects allow programs to manipulate the database in much more sophisticated ways, though they require more work on the developers part. The data control and DAO work closely together. Many programs, including PeopleWatcher, use a data control to manage basic interactions between text boxes and the database. They use data access objects to perform more complicated operations such as database navigation, record creation and deletion, and table management. The following sections describe the data control. If you already have a sound understanding of the data control, and if you know how to select records by placing SQL statements in its RecordSource property, you may want to skim this section or skip directly to the section, Using Data Access Objects.
|
||||||||||||||||||||||||||||
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
|