Loading...
image
Classic ASP has very rudimentary data access tools. You basically get ADO, a recordset object and thats about it. So I'm going to look at how you can turn these building blocks into an all purpose Data Access Layer.

Ongoing Projects

Microcyte Content Management System
Snatch (Mac OS X)
Snatch is a website scraping tool which can be used to retrieve links, images and email addresses from a given webpage and linked pages.
image
Distribution (Mac OS X)
Distributions is a mailing list management tool for Mac OS X. It features support for Multiple Classifications and some CRM functions.
image
??? (Mac OS X)
This is a new project I am working on for OS X (leopard). more soon!
image

Opinions & Views

image Previous | Next image

You may already have heard of Cloud Computing, Cloud Hosting is an exciting extension of this relatively new area.
I'm now back online after an outage in America caused my Hosting Provider some downtime.
Recently I had to convert a shed load on WMA's to work with iTunes on a Mac, heres how I did it at no cost.
As I work towards the 2.0 release of MicroCyte I wonder whether I should scrap XML/static files in favor of a database?
I've recently had the opportunity make extensive use of a 24" iMac 2.8Ghz, here's what I thought!
Recently I went to see Nizlopi perform at the Norwich arts centre, here's what I thought
MicroCyte has been released! head on over to microcyte.co.uk to checkout the demo and download your copy!
Very soon Firefox 3 will be released. This update will mean support for Microcyte CMS.
Regulars may have noticed that the site has been quiet for the last few days, click through to find out why!
In the last couple of days I've implemented a comments plugin for my Microcyte CMS
In Part 3 of building a DAL in Classic ASP I look at how I implemented my Dynamic SQL module to fulfull my DAL requirements
In part 2 of building a DAL in Classic ASP I look at how to create a functional Dynamic SQL module.
Classic ASP is not known for its rich data access tools, so I look at how you can build a strong Data Access Layer.
Are there compelling reasons for an old school scripting house to move to a new fangled framework?
After 9 months of work, the W3C has published the first working draft of HTML 5.
E-shots can help drive targeted traffic to your website, but how do you avoid making them look like SPAM?
A/B testing can be used to dramically increase conversions on your e-commerce site. Here is basic overview.
In the final part of 'how websites get hacked' I'm going to look at Social Engineering, the non technical hack.
In part 2 of 'how sites get hacked' we look at XSS and SQL Injection
In this brief primer we look at how websites get hacked and what to do to protect yourself (part 1)
After the hype has cooled down, what are the pro's and con's of the new Apple MacBook Air
Opinion: why is the Macbook Air a full 300 pounds (600 dollars) more expensive than in the US?

Data Access Layers in Classic ASP (Part 1)

What is a DAL
You hear the term Data Access Layer a lot when talking about building complex web applications in ASP.NET. But if you're working in Classic there doesn't seem to be much advice about. A Data Access Layer in the traditional sense of the term is a layer of code which acts as a gate-keeper to the database. All the database specific code and usually any code which derives a value from a simple calculation using values from the database is kept in the Data Access Layer (DAL for short). Simple validation can also be done in the DAL to help ensure that the database is kept consistent and clean.
 
ASP.NET has built up a variety of tools over the years to make the process of creating a DAL much easier and now its pretty much a drag and drop exercise, especially if you are using Microsoft products end-to-end. Classic ASP has been largely ignored is this regard so the developer is forced to build the DAL from scratch.
 
How Does a DAL typically work
ASP.NET and other technologies generally use what is called and Object Relational Mapping as a starting point for the DAL. What this means is that for every table in the database there is a class which represents the table structure and how the table relates to other tables. Each object instantiated from that class represents a row in the table. In that way an array of product objects can represent a table of product rows.
 
What does this gain you? Well essentially it means that you can give the database some intelligence about the data it's supposed to store. It can look at the data as it comes into the objects and make decisions about validation, data formatting, etc. It can derive more complex data from the data its given and store it without the business layer being cluttered. It can store statistics about how the data is accessed and stored. It can give you a more coherent picture about a group of related data fields without the developer having to worry about writing complex SQL statements. And along the same lines, a good DAL will abstract the database technology so any database system can be used with the application without affecting the other application layers (business logic, etc).
 
My own approach
When I built my DAL in Classic ASP I decided to take a different route and look at building a configurable Dynamic SQL module. This isn't really a DAL in the truest sense the word but is more flexible and can achieve many of the same things. The main goals of the project were to:
  1. Abstract the mechanics of the database from the Business and presentation layers.
  2. Format data coming out of the database in a configurable way
  3. Format and validate data going into the database in a configurable way
  4. Protect the database from SQL Injection attack
  5. Provide a shorthand syntax for accessing related data across tables
  6. Keep performance as fast as possible using sensible caching
  7. Make it easy and pain free to configure
  8. Automate processing of forms into the database with as little glue code as possible, where possible.
  9. Provide sensible validation warnings and errors to the business and presentation code where possible.
Essentially the aim was to build a black box class which had public methods for creating records, updating records, updating fields in a record and deleting records. Each of these operations would be fully validated and the code would do its best to escape any nasty data before it got inserted into the database. In this way I could achieve the look and feel of a traditional DAL without the hassle of creating libraries of stub objects for every project I wanted to use it with.
 
In the next part
In the next part I'm going to look at how I approached the design of the DAL to meet the project goals. I'm also going to start to look at some of the implementation and issues that arose.