Many people have asked how to do this over the years. Most solutions involved

a static presentation, which any novice can produce. I will attempt to illustrate

what it takes to bring your favorite dynamic website to your system, without

the big WWW... at all.

Stuff You Need

Let's Get Started

Assuming you, your computer, and any and all applications are ready to work...

  1. Start off by creating a Microsoft Access 97/2000 database.

    You can use a MS Access 2000 database but if you want greater compatibility

    to older systems such as Windows NT 4.0, 97 is the way to go. Just make

    sure you convert your database to 97 when you've finished modifying the

    2000 version.

  2. Next, you'll want to create your Dynamic HTML page.

    That's right. I said dynamic html page; no need to blink and/or rub your

    eyes. The following script will illustrate how to do so.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>

    <head>

    <title>My First Dynamic HTML Page</title>

  3. Add CD-Rom detection script.

    You'll need this to determine the exact path to the actual database (which

    will be located on the CD-Rom). This information is vital for step 4. The

    code below will pick out the correct CD-Rom drive regardless if you place

    your CD in the 15th bay of a 31 bay CD-Rom drive tower. The code will break

    if there is an identical database name as yours in another CD-Rom drive.

    To avoid this, just name your database something completely unique.


    <script language="VBScript">

    'Declare variables used in this code

    Dim CD_Rom, FilePath, DriveLetter, DriveType, FileSystemObject, Drives

    'Create a filesystem object

    Set FileSystemObject = CreateObject("Scripting.FileSystemObject")

    Set Drives = FileSystemObject.Drives 'Create a drives collection

    For Each DiskDrive in Drives

       DriveLetter = DiskDrive.DriveLetter

       DriveType = DiskDrive.DriveType

       if DiskDrive.DriveType = "4" then

          CD_Rom = DiskDrive.DriveLetter

          FilePath = CD_Rom & ":\YourDataBase.mdb"

          Set FileSys = CreateObject("Scripting.FileSystemObject")

          If FileSys.FileExists(FilePath) then

             'This is the correct

    CD-Rom drive.

             Exit For

          else

             'Keep trying

          end if

       end if

    Next

    'Clean up data usage

    Set Drives = nothing

    Set FileSystemObject = nothing

    Set FileSys = nothing

  4. Add the DSN script

    If you want to connect to any database, you'll need a "vehicle" to

    do so. A DSN (Data Source Name) is just want the doctor ordered.

    'Declare variables used in this code

    Dim Recordset1

    Recordset1 = CreateObject("ADODB.Recordset")

    Recordset1.ActiveConnection = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & FilePath & ";Uid=admin;Pwd="

    Recordset1.Source = "SELECT * FROM YourTable WHERE Conditions=Exist"

    Recordset1.CursorType = 0

    Recordset1.CursorLocation = 2

    Recordset1.LockType = 3

    Recordset1.Open()

     
  5. Finish off the script

    </script>

    </head>

    <body>

     
  6. Write your dynamic code

    Use this script as often as you need throughout your newly created dynamic

    HTML page.

    <script language="VBScript">

       if not Recordset1.Fields.Item("ColumnName").Value

    = "" then

          document.write(Recordset1.Fields.Item("ColumnName").Value)

       end if

    </script>

     
  7. Finish your HTML page

    You'll also want to close your database connection as good housekeeping practice.

    </body>

    </html>

    <script language="VBScript">

    Recordset1.Close()

    </script>

     
  8. Other Things to Add If Needed

    You're probably thinking, ok so all this does is display information from

    a database. I want to use this page as a template for lots and lots of

    information. What if I want to send this page a Product ID number or other

    variables that should help me determine what information to display from

    my new database. Here's how...

    Add this somewhere before your database call in your <script></script> tags:

     Dim ProductID

    ProductID = split(Location.href, "=")

    Then down in your database call add as part of your where clause:


     "... WHERE ProductID = " & ProductID(1) 

    When you used the split function above, you in essense created

    an array of variables. Product(0) contains your variable name like "ProductID".

    Product(1) should contain the actual number you wanted. For example, if you

    wanted to reference this page by:

    thispage.htm?ProductID=123

    ProductID(1) will contain the number 123. Since everything starts numbering

    at 0 :-) you can reference all your variables in your query string by referencing

    the odd numbers (i.e. ProductID(1), ProductID(3), etc.)

     
  9. Burn Away!

    Pay close attention to Step 3 in regards to where you should place your database

    on the CD-Rom. Currently the code should work if the database is on the

    root directory of the CD-Rom. If it resides elsehwere, just change the

    code to parallel your changes.

If you see anything wrong or need help with something in this tutorial, give

me a shout.