CD Trustee On The Web
ASP Scripts Setup, Part 1
Another pet peeve of mine is not being able to view setup instructions prior to download, so here
they are. Hopefully, you'll agree they're pretty simple and straighforward. There are only a few
things you'll need to modify on the scripts to get them to work on your website; the remainder of
your setup will be modifying them to match your site's look and feel.
Part 1 of the setup Instructions is a list of changes involved in customizing the scripts,
together with an explanation where necessary of how to make the change. Part 2 will be a list of
scripts and ASP files, an explanation of their purpose and instructions as to what, if any,
changes need to be made to customize them for your website.
Establishing the connection between your CD Trustee database and your web page using OLEDB.
This is best illustrated by example:
strDBPath = Server.MapPath("/db/CDTrust.mdb")
CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "; "
In the above example, you'll specify a directory path in the strDBPath statement. The directory
path is relative to the root directory, and setting it up is similar to specifying the relative
directory path for the images on your website. In the above example, my relative directory path is
/db/CDTrust.mdb. Just make sure you set this correctly, as you will get an error when you try to
run your web page if it is incorrect.
The advantage in setting up your database/web page connection in this manner is that nothing needs
to be setup through your web host's control panel. The connection between your CD Trustee database
and your web page is established directly inside the web page itself. If you need help determining
your directory path, you'll need to contact your web host.
Establishing the connection between your CD Trustee database and your web page using DSN.
This is best illustrated by example:
CONN_STRING = "DSN=CDTrust;"
Setting up a DSN is something you have to do from your web host's control panel. This is typically
a web page in which you logon with a userid and password that was setup for you when you signed up
for your web hosting account.
From the control panel, you'll create a DSN by entering the DSN name and specifying the directory
path in which your CD Trustee database is located. In the above example, we used a DSN name of
CDTrust. There's nothing magical about the name; it could be anything really. Just make sure the
name you setup on your web host's control panel is the same name you use in your ASP pages.
When specifying your directory path, this field may already be pre-filled with your root directory
path. If so, you'll just append the directory and filename to that pre-filled name. Again, make
sure you set up your directory path correctly; otherwise, you'll get an error when you try to
run your ASP pages. If you need help setting up your DSN, please contact your web host.
As to the advantage in using DSN, it's really just shorter code as far as I can see. Choosing DSN
or OLEDB is then just a matter of personal preference.
Setting the value for DateRange. This field is used in the
NewArrivals.asp page, and is the number of days that you wish for new entries in your CD Trustee
database to appear on this page. The example page has a value of 30, meaning that new entries show
up on this page for 30 days, then disappear. You can change this value to anything you like.
Setting the value of iPageSize. This value is the number of records
to display on each page. You can set your page size to any amount you want. Bear in mind as you
select this value that the larger the amount, the longer the time will be for your web page to load.
Setting the value for TableTitle. This field is used by
ArtistAlbumFormat.ssi, and sets the title for that page's table. For example, the web page title for
the Bee Gees & Related Collection page is also the value for TableTitle for that page.
Setting the value of varURL. This is the name of the web page you are
currently executing. Its value is used for database paging in the include file ArtistAlbumFormat.ssi,
and it should have the same name as the web page you're currently building. For example, the Bee Gees
& Related Collection sample page name is BeeGees.asp, so varURL for this page has the value
BeeGees.asp.
Setting the value of varWhere. I've saved the most difficult concept
for last, teaching you a little SQL. varWhere is the variable in the SQL Select statement which
filters database records according to desired criteria. Its format is:
WHERE condition(s)
A single condition in the WHERE clause has a format:
field-name = value
Multiple values of a single database field can be checked like this:
field-name IN (value1,value2,...)
Multiple conditions in the WHERE clause have a format like this:
field-name1 = value1 AND field-name2 = value2 ...
You can also join conditions like this:
field-name1 = value1 OR field-name2 = value2 ...
The WHERE clause might have both AND and OR conditions in it, and may or may not have parentheses
around them for grouping. Hopefully, you get the idea.
Let's look at the value of varWhere in the sample pages. BeeGees.asp has the following:
varWhere = "WHERE userfield1='Bee Gees' OR tblArtists.Artist IN ('Bee Gees','Andy"
varWhere = varWhere & " Gibb','Barry Gibb','Maurice Gibb','Robin Gibb') "
You'll notice that the value of varWhere is defined in two lines. The first line sets the initial
value, and the second line appends to the original value with the clause:
varWhere = varWhere & ....
Note that userfield 1 is the database name of the field shown
here.
This value is only available for CD Trustee version 2.
Some of the field names and values you may want to select for your web pages are:
tblArtists.Artist. This is all the artists in your CD Trustee database
tblAlbums.Genre. The values for this can be seen in the genre drop-down box on the Album Details
screen from your CD Trustee database. You can also view the complete list from Edit / Genre Table
Maintenance, which can be seen
here.
There may be other fields that you'd want to select, but these are the only ones that my scripts
use.
Note: This SQL tutorial is not meant to be exhaustive. In fact, entire books have been written on
the subject. However, I hope that I've given you enough information to be able to customize my
scripts for your own needs. If you've tried and failed to customize this part of the scripts, feel
free to contact me. I'd be happy to try and help.
Website hosted by WebHost4Life
Accessibility