PC Magazine -- January 9, 1996

Microsoft Corp.: Microsoft Visual Basic 4.0 Enterprise Edition

 

Visual Basic started life as a visionary way for mere mortals to build event-driven Windows programs. It became wildly successful as a database and client/server tool, so Microsoft added many specialized data-access features, but never transformed it into a database-only affair. An important and long-awaited new release, Microsoft Visual Basic 4.0 Enterprise Edition continues this line of development.

VB is now a fully 32-bit tool for building Windows 95 and Windows NT applications. With its greatly improved remote data access and significant new OLE-based object technologies, VB's support for database applications has never been stronger. At the same time, it lacks the single-minded focus and some of the bells and whistles of rivals that focus solely on database development.

We looked at the Enterprise Edition, which is targeted at teams of professional client/server developers. Version 4.0 also ships in a Professional Edition, for developing standalone databases and general-purpose apps, and a Standard Edition . The Enterprise and Professional editions both continue to support 16-bit development.

New jet

VB's Jet database engine has always been a key component for local and remote data access. While past Jet versions have been decidedly underpowered, VB now ships with the same 32-bit Jet 3.0 database engine included with Microsoft Access 95 (Jet 2.5 is also included to support 16-bit development).

Jet 3.0 provides many powerful new features, including engine-level referential integrity with support for cascading updates and deletes, field- and record-level data validation, primary-key enforcement, tunable caching of remote data sources, and password-based security. It also has built-in replication support, which will be of special interest for developers of mobile applications.

An enhanced Data Control offers a fast, straightforward way to give your application basic record-navigation, edit, and update functions (add and delete require coding). You can use it to access any database that is accessible through Jet, including Btrieve, FoxPro, dBASE, and Excel. As in Version 3.0, you can bind data-aware controls to the Data Control through their DataSource and DataField properties. The once-scanty set of data-aware controls has been beefed up considerably by the addition of a data-aware grid, list box, combo box, and OLE control.

Jet continues to provide Data Access Objects (DAOs), whose methods and properties give you the programmatic means to create, navigate, and manipulate databases. The only significant change here is the new Recordset object, which offers table, Dynaset, and Snapshot properties and more powerful methods for positioning the record pointer.

Remote Data through ODBC

ODBC remains one of the most important ways of accessing client/server data. Your applications can access ODBC data sources directly through the Jet engine and DAOs, or you can bypass Jet and use the new Remote Data control and Remote Data Objects (RDOs). Using Jet to handle syntax and data manipulation is the simplest approach, but the Remote Data control (essentially a VB wrapper to ODBC) and RDOs can offer better performance and a smaller application footprint. They also give you control over server-side cursors (including the type of cursor) and let you set pessimistic or optimistic update concurrency.

The Remote Data control and Remote Data Objects act very much like the local Data Control and Data Access Objects (see Figure 1). The Remote Data control provides basic record navigation and can be the data source for any of the data-aware controls like the grid or list box. For applications designed to work with Microsoft SQL Server, VB also provides a VB-specific DB-Library implementation. As in VB 3.0, you also have the option of coding directly to the ODBC API.

OLE automation objects

VB 4.0 now lets you write reusable compiled-code modules called OLE automation objects. This represents a major advance over earlier VB versions, where code reuse was always a primitive cut-and-paste affair. OLE automation objects are similar in concept to DLLs, except that the variables and storage of each instance of a class are protected from other instances. Unlike traditional DLLs, which are compiled machine code, VB's OLE automation objects (and all other VB executables) consist of p-code that is interpreted at runtime.

OLE automation objects are created by building Class Modules, which join code modules and form modules as a third standard type of VB source code object. OLE automation objects expose methods and properties defined in your class-module code through an OLE 2.0 automation interface. These can be called by your current VB application, other VB applications, and other OLE-enabled applications.

OLE objects that execute within an application's address space are called in-process servers. These are compiled with a .DLL extension. VB also supports the creation of out-of-process servers, compiled as .EXEs. These use an OLE proxy/stub mechanism to pass data between process boundaries (between your object and Microsoft Excel, for example). Communication between clients and out-of-process servers entails significantly more overhead than in-process communication. The advantage of an out-of-process server is that many OLE clients can use its services; with an in-process server, each OLE client needs its own copy.

Remote automation servers

By far the most interesting new feature in VB 4.0 is the ability of out-of-process servers and OLE clients to interact across a network. This feature, called remote automation, amounts to a form of distributed OLE, similar in concept to the operating system-based distributed OLE promised for the next major upgrade of Windows NT (code-name Cairo). The standard OLE proxy/stub mechanism is replaced by one that uses remote procedure calls (RPCs) across the network.

Remote automation raises the possibility of building partitioned or multitier client/server applications. The most common multitier scenario is a three-tier design, where three discrete systems are used for client application logic, business rules (tax calculations or order processing routines, for example), and the database server.

Multitier client/server application is a hotly debated topic, a client/server nirvana for some and anathema to others, who feel that business rules belong on the database server as stored procedures or triggers. If you're sold on multitier designs, remote OLE automation offers intriguing possibilities. It also raises some performance concerns because of network latency, RPC overhead, and the fact that the remote servers are interpreted. Although we did not run formal benchmark tests, remote OLE automation objects do not appear to be a good vehicle for performance-critical code. At the same time, they offer an excellent way to get business logic out of the user application and keep it in a centralized place where it can be easily maintained and updated.

The introduction of OLE automation objects gives VB a toehold in the world of object orientation. At the same time, VB is far from being a true object-oriented tool. You still cannot derive new classes from existing VB classes, and you can't base your classes on existing VB objects such as forms.

The Development Environment

The look and feel of the VB 4.0 development environment is generally unchanged. Controls are still clustered together on a single palette, although the addition of ToolTips and right-mouse-button support has certainly made navigation easier. VB still lacks a lot of the special tools database programmers need for repetitive tasks, however, such as building forms with large numbers of text controls.

The Visual Basic language has been brought into conformity with Visual Basic for Applications syntax. This gives it some useful new elements such as the line-continuation character (_) and the With statement. New #If and #EndIf statements let you embed conditional blocks in your code for supporting multiple targets. Support for resource files now makes it easier to create localized versions of your application. For development teams, VB 4.0 includes the easy-to-use Microsoft SourceSafe version-control package.

VB 4.0 introduces the new OLE-based 32-bit OCX control format. VBX controls are still supported, but only for 16-bit projects. VB includes an OCX replacement for all the original VBX controls. If your projects use only these controls, migrating existing source code to VB 4.0 is transparent; the environment simply prompts you to replace the old controls with new ones. If you used third-party controls, you must get OCX equivalents from the vendor. You must also update any API calls in your source code to the Windows 95 or Windows NT APIs.

More than ever, Visual Basic is a powerful if somewhat unusual tool for building database applications. Its new Jet engine, Remote Data control, and RDOs are a vast improvement over the previous release. OLE automation, Version 4.0's most significant breakthrough, provides a real strategy for code reuse and the first gleam of object orientation. The possibilities of remote OLE automation are intriguing and well worth exploring.


Microsoft Visual Basic 4.0 Enterprise Edition:  Microsoft Corp., Redmond, WA; 800-426-9400.

Class Modules now join code modules and form modules as the third standard type of VB source code object.