Beginning
Overview
IDE
Projects
Forms
Controls
Intrinsic Ctrls
ActiveX Ctrls
Code
Commands
Cmd Reference
File Handling
Printing
Distribution

Intermediate
Menus
Dialogs
Mouse
Drag and Drop
Graphics
Error Handling
Databases
Database Controls
SQL

Advanced
API
Objects
Internet File Transfers
UNIX/CGI/Perl
Perl Commands
JavaScript
Web Page Forms

GBIC >> VB >> Tutorials >> Databases
Databases
I've read in print that over 80% of all VB programs require the storage of user/application generated data. That's a pretty big percentage but based on my own experience it's probably about right. The real question is how many of those use database formats such as Access and how many of those use less complicated formats? There are major tradeoffs involved in the selection of a data storage scheme. In this section I'll talk about how to use the database features of VB, but I'll also talk about when those features are overkill and when simpler methods of data storage can be substituted for the VB database methods.


Data Storage

Let's get to the bottom line quickly on databases in VB. Microsoft has gone to great pains to add a lot of excellent methods for accessing data that is stored in not only Access databases, but other database formats as well. For beginner's they've done an excellent job! But even as I give praise to Microsoft for it's efforts, I can (and will) give you a few reasons why not to use VB's database features. But even with its negatives, I still chose to use database capabilities in a lot of my applications!

The huge penalty you pay for implementing those features is an enormous growth in the size of the program that you must distribute. Simply by putting in a single data control on a form, your distribution file size grows by over 5MBytes. Not only that, but database handling within VB is not anywhere near as fast as users might like it to be. The penalty you pay for features is a corresponding reduction in performance (i.e., speed)! But while the penalty is not trivial, it is not so great as to prevent VB programmers everywhere from using the VB data controls extensively.

Because of the negative aspects of using the VB database features, I look hard at my programs and do not automatically use the database handling capabilities of VB until I'm certain that the handling of the data by other means is not practical.

Another big negative of an Access database (or any other proprietary format) is the inability to edit the file directly. If the file were simple text, you could edit it in a variety of methods. In the proprietary format of Access you basically have to own another Microsoft product to edit the contents of the database.

Datbase Access - To Control or Not to Control!
VB has made it especially easy for beginners to utilize databases in their VB projects. With only one control (the data control) you can enable your program's other controls to display and edit data from the fields of that database. It really is that easy! VB also allows you to combine code and controls to quickly create very powerful applications.

VB also allows you to work with databases entirely in code, using no controls at all. The advantages to this are a greater level of control and faster performance. The penalty is that you have to do operations manually (in code) that the controls might have automatically done for you. I'll also cover this in more detail later.

Database Formats
While I don't use it all that much myself, VB also offers significant flexibility in the types of databases it can access. The software industry has agreed upon a standard way of accessing databases, known as ODBC (Open DataBase Connectivity). What this means to you is that using VB you are not limited to those databases which come from Microsoft. Even though the Micorosoft Access database format is an industry leader, VB nonetheless includes the ability to access other formats such as FoxPro, DBase, and others. You can even treat the contents of an Excel file or a text file as a database!