Visual Basic 4.0

Mike Otey explains some new features in the Visual Basic 4.0 Enterprise Edition.

Michael Otey

March 31, 1996

9 Min Read
ITPro Today logo in a gray background | ITPro Today

VISUAL BASIC (VB) 3.0 IS A POPULAR TOOL for developing bothstand-alone and client/server applications. A major reason for this popularityis that it enables Rapid Application Development (RAD). VB 3.0 lets corporatedevelopers quickly prototype and build Windows applications. As a result,although VB 3.0 is a single-user development tool, it has moved to the forefrontof client/server application development tools. For corporate developers,coupling VB's integrated Data Control and visual design environment with SQLServer's high-performance SQL database provided a robust environment forcorporate client/server application development.

However, specialized client/server development environments such asPowerbuilder have exposed some weaknesses in VB 3.0. While VB 3.0's Data Controlallowed very easy stand-alone program development, VB 3.0 was not as good forclient/server development. The Data Control and VB 3.0's built-in databaseaccess objects (DAOs) were built for local databases, not Open DatabaseConnectivity-enabled (ODBC) databases. VB 3.0's DAO is based on the Joint EngineTechnology (JET) originally built for Microsoft Access. JET's local queryprocessor resulted in inefficient ODBC calls and slow server data accesscompared to more efficient specialized client/server tools such as Powerbuilder.

Furthermore, VB 3.0 has no team application-building facilities: It istargeted at the single developer. Coordinating the work of multiple developersis no easy task in VB 3.0; for multiple developers to concurrently work on thesame project, manual conventions or third-party tools are necessary. On top ofall this, VB 3.0 can build only 16-bit applications--it cannot develop native32-bit applications for Windows 95 or Windows NT.

Client/Server Capabilities
Microsoft addressed these problems in the 4.0 release of Visual Basic, a 16-and 32-bit development environment that builds on the successful foundation ofVB 3.0. For starters, VB 4.0 introduced a new version called the EnterpriseEdition. Aimed clearly at the corporate client/server developer, the VB 4.0Enterprise Edition takes up where the VB Professional Edition leaves off. Themost important client/server feature in the new Enterprise Edition is ahigh-performance RemoteData Control. Unlike VB 3.0's Data Control, which isbased on the JET engine, the new RemoteData Control provides a thin wrapper overODBC. The ODBC orientation lets the RemoteData Control perform better whenyou're accessing ODBC databases such as SQL Server.

Microsoft also boosted VB 4.0's client/server development capabilities byadding the ability to create Object Linking and Embedding (OLE) servers. OLEservers let you create three-tiered client/server applications: The businessrules are encapsulated in an OLE server program that is separate from both theclient application (which typically contains the user interface) and thedatabase server (which contains the data tables an application uses). You cansee the evolution of VB in table 1.

VB 4.0 Enterprise Edition also provides team application-buildingcapabilities through the integration of Microsoft's Visual SourceSafe.You call Visual SourceSafe directly from VB 4.0's menu, and Visual SourceSafesupports source control through check-in and check-out functions and projectversion control and history. For more information about using SourceSafe with VB4.0, refer to the sidebar, "Team Development with VB 4.0 EnterpriseEdition," on page 78.

VB 4.0 includes several client/server database access alternatives. Let'squickly look at the options to understand the differences among them and seewhere each option works best.

  • The Data Control: VB's Data Control and DAO use the Microsoft JETEngine and were originally intended to support the Access database. The DataControl and the other VB bound controls make program development very easy, butthey also introduce undesirable overhead for accessing remote data sources suchas SQL Server. This situation makes the Data Control and the DAO best suited forapplications that need to access data only on the local system.

  • The Visual Basic Library for SQL Server: The Visual Basic Libraryfor SQL Server (VBSQL) provides a high-performance method for accessing SQLServer databases. VBSQL does not support bound controls, so application codingis required for database access. Although VBSQL provides complete access to thecapabilities of SQL Server, this SQL Server-only focus is a double-edged swordthat also limits VBSQL to use only with SQL Server. Likewise, all the majordatabase vendors (e.g., Oracle, Sybase, IBM, Borland) provide similar librariesfor accessing their respective databases. All these options provide good client/server performance, but they also lock you into one vendor's database.

  • The ODBC Application Programming Interface: Coding directly to theODBC application programming interface (API) provides high-performance remotedatabase access and portability to multiple database platforms, but thisapproach does not support bound controls. The ODBC API is a collection of 56functions, and implementing it in your applications requires substantial codingand a good understanding of this API. It's like the inverse of the VBSQL librarybecause the API's standardized database support lets it work with many differentdatabases, but it doesn't support any vendor-specific implementation featuresthat are unique to a particular database. Although you can use ODBC for localdatabase access, it's really best suited for accessing remote SQL databases suchas SQL Server, Oracle, and DB/2.

  • The RemoteData Control: As you can see, each of these methods hasits purpose, but each also leaves something to be desired. VB 4.0's RemoteDataControl and Remote Data Objects (RDO) attempt to provide the best of bothworlds: easy program development and high-performance data access. TheRemoteData Control combined with the other VB bound controls makes no-codeclient/server database access easy and provides good client/serverperformance. Because the RemoteData Control is based on ODBC, it's also suitablefor multiple-platform database access. This potent combination is likely to makethe RemoteData Control and RDO your first choice for client/server databaseapplication development.

Taking Control
Screen 1 presents the VB 4.0 development environment. You can see the newRemoteData Control and the other data-aware custom controls that are a part ofthe VB 4.0 Enterprise Edition. The appearance of the RemoteData Control issimilar to the Data Control. Both the icon in VB's toolbox and the control thatappears on the form look just like the old Data Control. However, the RemoteDataControl is new and is implemented with the 32-bit MSRDC32.OCX found only in theVB 4.0 Enterprise Edition.

The differences between the RemoteData Control and the old Data Controlbecome apparent when you look closely at the properties of the RemoteDataControl. Not surprisingly, the RemoteData Control properties are closely modeledafter the parameters that the ODBC API uses. For instance, in screen 1, you cansee the properties of LockType, LoginTimeout, Password, ReadOnly, ResultsetType,RowsetSize and SQL. All these values are manifestations of various ODBC APIfunction parameters, and this close relationship with ODBC lets the RemoteDataControl provide good client/server performance.

TABLE 1: The three Visual Basic 4.0 Editions.

VB Edition

Price

Features

Visual Basic Standard Edition

$99

32-bit Applications Only32-bit Data Control and DAOBoundControlsLocal Database Support(Access, Paradox, dBASE, Btreive)

Visual Basic Professional Edition

$499

All the features of VB Standard Edition32-bit and 16-bitApplications20+ Additional Custom ControlsODBC Database SupportSQLServer and ORACLE ODBC DriversIntegrated Data ManagerOLE Server andComponent CreationHelp CompilerSetup Toolkit

Visual Basic Enterprise Edition

$999

All the features of VB Professional Edition32-bitRemoteData Control and RDOIntegrated Version Control (Visual SourceSafe)DataExplorerRemote OLE AutomationComponent Manager

Put to Work
With a basic understanding of VB 4.0's new RemoteData Control under ourbelts, let's put that knowledge to work by using this facility to connect to anSQL Server database. First, to use the RemoteData, you click on its icon in VB'stoolbox and then drag-and-drop it onto your VB form. After you add the controlto your form, you must set its connection properties by clicking with the rightmouse button on the RemoteData Control. The RemoteData Control connectionproperties window you see in screen 2 will be displayed.

The Data Source text box lets you enter the data source name you want toconnect to. The example in screen 2 shows how to connect to a data source namedTECADB, which is a SQL Server database in this example. You can manually enterthe name of the data source, or you can click on the drop-down box, and a listof all available data sources will be displayed. One important point is thatbefore you can use the RemoteData Control to connect to a data source, you mustdefine that data source by means of the ODBC Administration program.

The next set of prompts lets you enter the user name and password foraccessing the SQL Server database. Finally, you enter the SQL statement in theSQL text box. This is the SQL statement that will be sent to the SQL Serverdatabase. This statement identifies the database tables to use and the rows andcolumns to select. You can enter any valid SQL statement. The simple SQLstatement select*fromaccount in screen 2 selects all the rows and all thecolumns from the table named "account."

Note that this simple example is for illustration purposes only. As ageneral rule, you won't code such inclusive SQL statements. Consider whathappens if you run this statement against a table containing a million rows.Your application will attempt to retrieve the entire million rows. Instead, youlimit the amount of data that your application deals with by coding a morerestrictive SQL statement, such as

select number, description, amount from account where amount > 50000

After setting the connection properties of the RemoteData Control, you needto add a bound control to your VB form. To add the new DBGrid Control, yousimply select the DBGrid Control from the VB toolbox and drag-and-drop it ontoyour form. After you add the control to your form, you must set its Data Modeand Data Source properties. This example uses a Data Mode property of 0 -bound, which sets up this control as a bound control (a bound control isautomatically linked to the Data Control or RemoteData Control named in the DataSource property). I set the Data Source property to the RemoteData Control namedMSRDC1. If you want, you can also specifically set each column in theDBGrid Control to a column from the SQL table, using the Columns property formin the DBGrid's Custom dialog. If you leave this property blank as in thisexample, the grid will automatically create a column for each SQL databasecolumn that the SQL statement returns. Running the new application results inthe window shown in screen 3.

The resulting application is a native 32-bit Windows program that can runon either Windows 95 or Windows NT. When the application starts, you receive aprompt to log in to the SQL Server database. Then the SQL statement you enteredinto the RemoteData Control is executed, and the data is returned from the SQLserver database and displayed in the grid. If you set the AllowUpdate propertiesof Grid to True, you can edit the data presented in the grid.

That's all the programming you need to begin writing high-performanceODBC-based client/server applications with VB 4.0's new RemoteData Control. Inaddition to the RemoteData Control, VB 4.0 has Remote Data Objects (RDO), whichprovide a finer level of control over ODBC database connections.

Layer of Performance
VB 4.0's RemoteData Control brings both RAD and high-performance ODBCdatabase access to your 32-bit application development environment. TheRemoteData Control's thin layer over ODBC ensures good performance when youaccess remote databases such as SQL Server, and its easy, no-code programmingallows quick application development. For client/server application development,the RemoteData Control and RDO make the VB 4.0 Enterprise Edition worthconsidering. The RemoteData Control and the other client/server enhancements tothe VB 4.0 Enterprise Edition make it a strong competitor to any specializedclient/server development platform.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like