DBPix Samples: ASP Publishing

View Sample   Documentation   DBPix Site


Sample Documentation.

Overview
This sample illustrates how to publish an image database on an IIS web-server.  The content is administered either by using Access forms to update live data on the server or by updating an offline copy of the database and copying/uploading it onto the server. 
Platform & System Requirements
DBPix Control version 2.0 or later. 
IIS/PWS 4.0 or later. 
Access 2000 or later. 
Suitable database connection/drivers on the webserver, such as ODBC or OLE DB. 
Any web browser.
Installation
Unzip the file into a new folder on your IIS web server, ensuring that the directory structure is reproduced.  Ensure that the IIS configuration allows script access to the top-level folder. 
Files

Filename Description

default.asp Main sample page which displays a list of thumbnail images from the database.  View Page Source
detail.asp Displays the main (detail) image for a particular record from the database. View Page Source
getimage.asp Server script to return an image (detail or thumbnail) from the database. View Page Source
adovbs.inc ADO constants include file for VBScript. View Page Source
config.inc Configuration file containing connection strings. View Page Source
readme.htm This file.
viewcode.asp Utility script to view source code.
asppub2k.mdb  Database containing the images.

Configuration
If your system supports the "Microsoft.Jet.OLEDB.4.0" provider (as installed by MDAC 2.5 or later) then no further configuration is necessary.  Otherwise edit the 'config.inc' file located in the top-level folder and update the connection string as indicated in the file.   If necessary you may need to set up an ODBC connection.  For more information on configuring connection strings see the resources listed on the links page at www.ammara.com 
Walkthrough
Connect to your web-server at the url corresponding to the installation path. 
You'll see a simple list showing the image for each record in the database along with some textual data.
Open the asppub2k.mdb file in the 'database' subdirectory on the webserver.  Open the 'Photos' form and scroll through the records viewing the associated images.  Scroll to a new record, right-click the large image control and click 'Load' to add a new image from the local filesystem.   Close the form, then refresh the browser to review the new entry. 
Technical Summary
The Start Page (default.asp) is generated by querying the 'tPhotos' table. For each row that the query returns, a row containing an HTML image tag is added to an HTML table. Instead of referring to a specific image file the image tag points to another asp script, with the Id of the required image as a parameter.  Additionally the image tag is completed with the dimensions of the image which were stored in the database.  When the browser requests the image from the webserver the request is handled by the getimage.asp script which retrieves the image from the database and returns it to the browser just as if the browser had requested a regular image file. 

The image tags are generated by the following ASP Code:


<img src="getimage.asp?field=Image&imgid=<%=oRS("Id")%>" width="<%=oRS("Width")%>" height="<%=oRS("Height")%>">

which is seen by the browser as:

<img src="getimage.asp?field=Image&imgid=21" width="140" height="90">

See the links to the source code above to examine the files in more detail.
More information
Additional samples and documents are available from www.ammara.com and cover topics such as Thumbnails, remote updates over HTTP and many other issues.
Note that these samples are simplified for clarity. In a production system consideration should be given to such issues as error-handling, optimising for cacheing, security, server-loading etc. For more information see the FAQ's and articles in the support areas at the DBPix product website