Using ADO

In the Visual Basic, there are lot of methods and tools to access database, such as DAO, RDO, ADO, as well as many native access interface to specific database.

These methods and tools are very useful for VB Web Application to link Website to the database. Similar to Windows Application, the VB Web Application normally retrieve user input through HTML FORM first, then process these input and access the database, finally return the result to the user through Web Page. All database access methods and tools used for Windows Application can be used for Web Application.

In this section, we use the sample program AccessDB to show how easy the database access in VB Web application with WebRainbow. This sample uses ADO and MS Access database to handle user Login and maintain the user's profile. Same as the other samples, this sample only use one program to generate 3 pages (Logon page, User Profile page, Exit page) to make it easy to test.

Note:

  1. For the real practice, these pages may be handled by several separated programs to make executable as small as possible for the best performance.

  2. The VB source code is only for Visual Basic 6 & 5, because it uses ADO. Click the link to see the AccessDB.bas.

  3. This sample still keeps static sections separated from dynamic section (this is not required, just we think it may be convenient for coding and developing):

To compile this sample, follow the steps list bellow:

  1. Start Visual Basic

  2. Select Standard EXE as project type

  3. Select Sub Main as Startup Object

  4. Give AccessDB as project name

  5. Set reference to WRHttpB.tlb, WRMimeB.tlb, WRnbwB.tlb, and ADO Object:

  6. Remove Form1, which is the default form for new VB project

  7. Add AccessDB.bas into the Project AccessDB. This file is normally in the folder
    C:\Program Files\WebRainbow\demo\accessdb\ if you did not change the installation directory for WebRainbow.

  8. Compile it to AccessDB.exe.

To create an Access Database, follow these steps:

  1. If you did not change the installation directory for WebRainbow, in the folder
    C:\Program Files\WebRainbow\demo\accessdb\ there should be these three files:
    • survey.txt
    • country.txt
    • comp_lang.txt.

  2. File survey.txt is the database structure for survey.mdb, please use the table name, field name defined in this file to create an Access database survey.mdb.

  3. Import data to tables country and comp_lang from country.txt and comp_lang.txt.
    Note: The first line of these two files is field name, it should not be imported to survey.mdb.

  4. Leave tables "users" and "users_backup" empty.

To debug AccessDB, the survey.mdb should be in the same folder with AccessDB.vbp. click on Debug in VB IDE for detailed instruction.

To run this sample, click on the following link for instruction of


For the latest information on WebRainbow, please see:
http://www.dmfsys.com/wrainbow/

For questions / comments please email to:
support@dmfsys.com


Copyright © 2000 - 2005, D.M.F. Systems, Corporation. All rights reserved.

Last modified on March 2, 2005