Important alert: (current site time 7/15/2013 10:01:45 PM EDT)
 

article

A Complete Database Accessing Web Site!

Email
Submitted on: 5/21/2000 9:33:45 PM
By: Bob Lee 
Level: Intermediate
User Rating: By 39 Users
Compatibility: ASP (Active Server Pages), VbScript (browser/client side)
Views: 210138
 
     This article not only includes the complete source code for a database driven web site that the author created, but includes a detailed description on how it works!

This article has accompanying files

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				

Background

I set up the admissions site at my college as what I like to think of as a web application as opposed to a bunch of web pages. It is an ASP application that pulls all of its information- menu titles and links, sub menu titles and links, and page content- from a database. The information retrieved from the database is determined by parameters passed through the query string. All of the menu links on the page link back to this main page with a query string. For example, when you click on a main menu link on the nav. bar, the page reloads with the main menu item's corresponding content and all of the sub menu links listed under the main menu link. If you are interested in how the tables are set up or the links are generated, please email me.

There are administration pages that allow non-computer savvy people to add and remove menu items and content to and from the database, thus modifying the web site. These people were not satisfied with the menu items simply being displayed in alphabetical order. They wanted to come up with their own order.

How it works

I started out by adding an additional numerical field to the menu tables in the database called zorder. A text box corresponding to this field was added to the admin pages and the main page was modified so that when it loaded the menu links, it sorted them by their zorder field first and then their title field, whereas before they were sorted only by the title field. If the user left the zorder field blank, I could have done one of two things: give that item the next available zorder number making it the last in the list; or give all items with blank zorder values the same maximum zorder value thus making them all be displayed alphabetically at the end.

I would have liked to just leave it at this, but I foresaw two problems: these same non-computer savvy people having problems with the idea of using a zorder field on the admin pages, and I would get tired of manually updating all of the zorder values every time I wanted to insert a menu link.

First of all, I labeled the zorder field on the entry and edit forms Menu Position and I used a drop down box of numbers to prevent users from entering erroneous values. The drop down box contained the numbers from 1 to the maximum zorder number and defaulted to the last possible number (1 plus the maximum zorder numer) when they were adding a new item and to the existing zorder number when they were modifying an item.

If the user enters a zorder number that is already in use, you will have to update the following zorder numbers accordingly. Given that selectedzorder refers to the zorder number (menu position) that the user selected for the current record then the following SQL query will perform the required update on the following menu records:

Update main_menu set zorder=zorder+1where zorder >= selectedzorder;

To retrieve the maximum zorder value for use in your drop down box you could use this query:

Select Max(zorder) from main_menu;

The same rules apply to the sub menu table with obvious modifications.


Installation

To install the web application, just un-zip or un-Rar the attatched file into a directory on your ASP-enabled server. I just have mine in the root of my PWS.

If you set it up like I did you would access the demo home page like this: http://localhost/default.asp
and the admin page like this: http://localhost/admin/default.asp

The database is stored in the admin directory. Password protect the admin directory to protect the admin pages and the database. From there it's all pretty self explanatory.

New features allow you to make that menu hierarchy as deep as you like, and the order of menus is now changed with little arrow buttons. I also re-wrote the interface on the front of the admin page and added a site statistics page. Plus, you can cut and paste entire menu trees! This makes it so easy to reorganize your site.

I'll apologize in advance for the lack of commenting and some of the obscure code in places. I usually don't go to a lot of trouble on comments on something this small and straight-forward not to mention it's the product of quite a few late nights. If you find any blatently bad coding, please let me know.

I worked pretty hard on this; if you decide to use part of this code or the entire application please give credit where credit is due. I am a very poor college student who likes computer toys and fine beers (a lot), so if you decide to use this for commercial purposes (i.e. your business's intranet or Internet site) you have to pay me something out of common courtesy and your profits (heh, heh, j/k).

In any case, I'd love to see how you guys apply this. E-mail me with links and descriptions! If you think this calls for another article, let me know and I'll throw something together and submit it.

Thanks for all of you interest in my first article!!

Note: you must have ADO 2.0 or greater installed, since the OLE-DB driver is used in connect.inc. You can download ADO 2.0 for free, or you can just alter connect.inc so it uses a DSNless connection or a System DSN.

winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
7/4/2000 6:03:00 PMhoward

interesting article, but still do not understand. can you help me?
howard@russialink.couk.com

(If this comment was disrespectful, please report it.)

 
7/25/2000 4:46:16 AMVTech

Hello,

Do you want to work for us,
we have a similar application to develop !

Thanks
(If this comment was disrespectful, please report it.)

 
10/23/2000 6:28:58 PMYuntan@mail.com

what do I need to change to run this applet with Access2000?


Microsoft JET Database Engine error '80004005'

Unrecognized database format 'C:\Inetpub\wwwroot\exADODB\admin\webdb.mdb'.

/exADODB/connect.inc, line 3

the databse engine?

is there a new one for use with 2000?

(If this comment was disrespectful, please report it.)

 
1/30/2001 7:46:35 PMAndy

Just what I needed...Working Examples Rock for learning!! Thanks
(If this comment was disrespectful, please report it.)

 
2/20/2001 8:07:59 AMStephen Griffin

Hi , very good as a start , I am an MCSE but need to try and get into ASP And HTML and Web development in whole.
I need to write to this DB ,how do i create a page to do that?

thanks

stephen griffin

mailto:stephen.griffin@ireland.com
(If this comment was disrespectful, please report it.)

 
5/4/2001 6:05:47 PMApinzon

Excelente código te permite crear toda una intranet en minutos...

Gracias!!!
(If this comment was disrespectful, please report it.)

 
6/20/2001 5:04:20 PMLewis Moten

Cool! I'm gonna set this up on my friends website for them.
(If this comment was disrespectful, please report it.)

 
6/27/2001 7:20:08 AMbambang

it was a great site i ever see
keep goin' with all computer's knowledge
thanks.
(If this comment was disrespectful, please report it.)

 
9/6/2001 3:57:27 AMRobert

as a rookie with this stuff, i am wondering how to install ADO. the microsoft site does not give me enough info. can you help me out?

thx
Robert
(If this comment was disrespectful, please report it.)

 
12/17/2001 8:08:45 AMKevin Therriault

Thank you for your most informative Code and Website. I found it well written and easy to comprehend for a beginning ASP Coder.
(If this comment was disrespectful, please report it.)

 
4/29/2002 6:04:29 AMArvind

Do you have any source that like Registation page, contacu us page, post add your resume type.

IF yes kindly send to me. Plz.
(If this comment was disrespectful, please report it.)

 
7/5/2002 3:41:52 PMBrad

what do I need to change to run this applet with Access2000? Microsoft JET Database Engine error '80004005' Unrecognized database format 'C:\Inetpub\wwwroot\exADODB\admin\webdb. mdb'. /exADODB/connect.inc, line 3 the databse engine? is there a new one for use with 2000?
(If this comment was disrespectful, please report it.)

 
7/25/2002 1:50:13 PMVinh

It is an excel code as I voted. Could you please write a ASP read and update record from an existing database? Also a confirm message for Reset button.

Thank you so much.
An ASP novice from Texas.
(If this comment was disrespectful, please report it.)

 
7/29/2002 11:15:10 AMPeter Tran

I've received same error msg.

what do I need to change to run this applet with Access2000? Microsoft JET Database Engine error '80004005' Unrecognized database format 'C:\Inetpub\wwwroot\exADODB\admin\webdb. mdb'. /exADODB/connect.inc, line 3 the databse engine? is there a new one for use with 2000?
(If this comment was disrespectful, please report it.)

 
9/24/2002 11:45:09 PM

Hi Bob, the concept of the code is great, but I've a problem. Having unzipped the code to my ASP server it won't read at all - I get a "page cannot be displayed" error. Could you advise please, but as I'm new to ASP could you be very basic, please? Thank you!
(If this comment was disrespectful, please report it.)

 
10/15/2002 9:58:50 AMThnder

This link to ado updates download and run em http://www.microsoft.com/data/download.htm
(If this comment was disrespectful, please report it.)

 
11/6/2002 12:46:10 AM

Dear Mr. Bob Lee,
I voted "Excellent" for this project.
I think this is one of the best ASP code I have tried. Thanks from all of us (ASP Training Centre) in PAKISTAN.
(Nov.6, 2002)
(If this comment was disrespectful, please report it.)

 
11/30/2002 11:14:24 PM

I like your idea very much. But, I get a "page cannot be displayed" error. Could you please advise me, as I'm a beginner to ASP. I don;t mind learning new stuf. I would really appreciate it if you could help. Thank you!
(If this comment was disrespectful, please report it.)

 
12/12/2002 12:08:22 AM

The code given above is very nice and useful to me.
(If this comment was disrespectful, please report it.)

 
2/24/2003 11:50:01 PMnfs

You will rule in ecommerce.
Cool work.
Do you want to make money with your programming skills ? Software Objects provide following services :
1)Sell your software.
2)Post
a software to be done.
3)Bid on the software projects.
4)Buy software
Thanks and have a nice day.
Software Objects
http://www.thesoftwareobjects.com

(If this comment was disrespectful, please report it.)

 
3/5/2003 9:55:20 AMAbdul Rafay Mansoor

Hello every one !
I have a question for WebMasters.
If I build a DataBase driven web site,like this one, will google crawl my website .. will my website be indexed in google???

Thankx :(|)
(If this comment was disrespectful, please report it.)

 
4/9/2003 6:09:30 AM

Very nice code!
Anyone having prolems with connection.inc? Change it to :
<%
Set db = Server.CreateObject("ADODB.Connection")
db.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("admin\webdb.mdb")
%>

(If this comment was disrespectful, please report it.)

 
7/14/2003 1:16:35 PM

This is just what I need but cannot get past calling either defaults up in IE6 where the following message appears.
Error Type:ADODB.Connection (0x800A0E7A)
Provider cannot be found. It may not be properly installed.
/connect.inc, line 3.
Can anyone point me in the right diection for W2000 & IIS
(If this comment was disrespectful, please report it.)

 
1/4/2004 8:32:09 AM

i like to get some source code for changing color's text. The text will be changed after 3 and 6 days..i hope you can help me..!!please send me some example source code at mayang7@yahoo.com or azzahrah7@yahoo.com..thank's
(If this comment was disrespectful, please report it.)

 
1/4/2004 8:38:22 AM

i have some problem in ASP language programming..so.I like to get some example source code for ASP to improve me in web programming.I hope our member who read this message can help me..Please contect me ... mayang7@yahoo.com..thank's
(If this comment was disrespectful, please report it.)

 
5/22/2004 10:27:04 PM

Interesting article...
(If this comment was disrespectful, please report it.)

 
8/3/2004 6:02:48 AM

Very nice code,but i have a little problem.I'm an ASP beginner. The code if working on my computer but if I try it on a server, I get HTTP 500 - Internal server error. Any ideas?Thanks for your help.
Uros
(If this comment was disrespectful, please report it.)

 
9/25/2004 3:45:19 AM

please send me complet address book coding in "ASP" & "VB"
Thanks
(If this comment was disrespectful, please report it.)

 
11/30/2004 5:25:55 PM

bu ne be çokyarım kalmış ASP hazır site
(If this comment was disrespectful, please report it.)

 
12/9/2004 3:18:00 AM

Hi friend Thanx for making Planet Source code the best site on net.its becoz of u people that programmers like us get every line of code .Thank u once again
(If this comment was disrespectful, please report it.)

 
2/8/2005 2:51:32 AM

how to link to database if we develop search engine website
(If this comment was disrespectful, please report it.)

 
3/28/2005 2:50:35 AM

Good Site
(If this comment was disrespectful, please report it.)

 
3/28/2005 2:51:29 AM

good site

(If this comment was disrespectful, please report it.)

 
6/13/2005 7:17:52 AM

Dear Sir,
i am facing problem in asp. i am using database in sql server and i am unable to retrieve records against DATA i.e. select Order from Orders where Order_Date = ""

i hope that u will solve my problem
regrds
adeem

(If this comment was disrespectful, please report it.)

 
8/21/2005 12:19:40 PMsri

good code, thanks to planet source code.
(If this comment was disrespectful, please report it.)

 
4/22/2006 4:28:24 AMkrishna

hi Boob, my name is krishna, i am Beginner, now i am learning asp, I saw Your code on planetsource code. I download u r application, and i create one folder inside wwwroot(AAComDB). AAComDB - This is Folder name.
I paste your Code in this folder. i run defalt page. http://localhost/AAComDB/default.asp
and i also run inside the admin defalut page.
http://localhost/AAComDB/admin/default.asp.

its shows nothing in my browser. please guide me and Help me.
(If this comment was disrespectful, please report it.)

 
6/28/2006 3:49:31 AMasif

very nice site...relay i like it
(If this comment was disrespectful, please report it.)

 
1/17/2007 1:53:37 AMh0ney

i'm having some problem to download ADO 2.0.can anyone sort me out?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.