Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Database Abstraction in ASP
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Database Abstraction in ASP

 Post Reply Post Reply
Author
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Topic: Database Abstraction in ASP
    Posted: 07 June 2004 at 6:53am
I'm in the midst of beginning a new ASP project and the goal is to be able for the project to work despite the database back end AND for the SQL statements to be customized for the database. However, I have no desire to mix the SQL information with the ASP code.

In looking at projects such as SNITZ and WWF, I've noticed 2 methods.
1) Treat all databases the same and use a single set of SQL statements for them all (SNITZ method)
2) Separate the SQL statements and attempt to optimize for MSSQL by using stored procedures.

The problem I have with both methods is neither truly uses the power of MSSQL to its full ability. The greatest power of MSSQL is the ability return multiple recordsets and if you are treating it like ACCESS, you lose this ability and thus lose the main strength of MSSQL.

My thoughts for a solution is to separate all SQL statement into include files and based on the complexity of the page use a separate SQL include per page or a united one. For instance, something like the front page of this forum would have a SQL include for the common SQL tasks (such as the login check) and then a separate SQL include file for returning the main data for the page. The SQL includes would return recordsets populated into arrays.

The benefits of this solution is that all SQL quesries are separate from the display. This means if ACCESS is used then you drop in the ACCESS SQL files and it's optimized for ACCESS. If MSSQL is used you drop in the MSSQL files and ditto for MYSQL and another other supported database.

The disadvantage is that in order to cut down on the potential size of the SQL include file, there would be more total files in the project. For a project like WWF that could easily double the file count. However, I have not found an alternate solution.

For one of the e-commerce applications that I developed in the past, I placed all the SQL statements into one file and used page variables to select the correct SQL statement. The result was an 130 line function to be included into every page. That works beautifully for MSSQL because all the SQL statements are stored procedures with application having over 50 stored procedures. The SP for the add to cart function itself was over 47 lines of SQL code, so to replicate it in access would have taken at least 47 lines if not more. That would have resulted in a severely bloated include file if all the SQL statements were included in a single file.

I'm sure there's a point in here some where, but basically, what I'm pondering out loud. Has anyone solved this problem in classic ASP? How? What other methods have you considered?
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 07 June 2004 at 10:02am
Depending on how advanced you application is you can write a COM Component, acting as a Data Access Layer. You could have a component for whichever Database and it returns data always in the same way i.e. array. That way it does not matter what DB backend you use, all you do in the asp applications is call it's method... Of course, this is not usually doable for "freebie" applications whereas most ppl don't have access to register com.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 07 June 2004 at 10:05am
No COM objects, this is to be just ASP files only using standard components.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.