To read the article online, visit http://www.4GuysFromRolla.com/webtech/022100-1.shtml

Online Database Editing Program

By Richard Chisholm


Here's a not so hypothetical situation. My web site is on a hosting company's server. I have a couple of databases up on it, but if I want to edit them normally I'd have to use FrontPage to access and download the whole thing. With a large database we're talking about a serious wait over a modem. Or how about this one: you need to have a person edit an online database, but they don't have access to the server. That's where this application comes in handy. After reading "Generic ASP Database Editor for Access Tables" by Roman Koch and using his app, I felt that by building a couple of layers on top of Roman's page, I could accomplish what I wanted. Namely an easy way to add/edit/delete records on any database in a web site without accessing it directly.

While fully acknowledging Roman's effort, I feel what I have done adds a lot of functionality. Basically I have merged Roman's editor app with a process I read about on ASPToday.com in an article called "Dynamic ASP/JavaScript for Data Refresh." In that article, a frames page is used where one frame set to 100% is used for displaying the content, while the other (set at 0% of course) is an ASP page and does all the processing of the logic. The app that I wrote uses the display page to show the user available databases and tables, while the logic page(s) are responsible for determining what databases/tables are available. Using the frame display/logic process works well because it integrates well into existing templates, and it eliminates the overhead by only loading the display page HTML once.

Now, before I get started let me say a few things:

    1.) First, check out Roman's article (read more) and the ASPToday article (read more) to get the basic info on his asp scripts. For my app, the script that Roman wrote is left on a separate asp page, and includes his notes & comments. I have made slight modifications to his script, and I have noted the areas where I this occurred in the script (and I will also do the same here).

    2.) This app is probably a resource hog. It uses Session variables and connects many times to the database, opening both recordsets and schemas. While this is certainly a useful tool for a few people, I really wouldn't recommend it for any significant number of users. (See Are Session Variables Really Evil? for more information!)

    3.) Finally, because this uses the id.innerHTML = DHTML property, only Internet Explorer 4.0 or greater will work with this app.

This app is composed of the following files:

  • db-admin.htm (the frames page)
  • display.htm (the "display" page)
  • logic.asp (has all the asp script to process the requests)
  • dbedit.asp (Roman's asp script)

First off the frames page. I don't need to put the source here, just make it two rows named display and logic set to 100% and 0% respectively. The display.htm is your template web page with two additions: one JavaScript function, and the login HTML.

JavaScript:
<script LANGUAGE="JavaScript">
	function go()
	{
	var user = document.login.name.value;
	var pass = document.login.password.value;
	var loc = 'login.asp?';
	loc += 'type=login&';
	loc += 'name=' + user + '&';
	loc += 'password=' + pass;
	top.logic.location.href = loc; 
	}
</script>

HTML:
<span id="url"></span>
<form name="login">
<span id="text"><p>Please login: </p>
<table border="0" cellpadding="2">
	<tr>
      <td width="50%">Name:  <br>
          <input type="text" name="name" size="20">
	</td>
      <td width="50%">Password:<br>
          <input type="password" name="password" size="20">
	</td></tr></table>
<p><br>
<input type="button" value="Submit" onclick="go()">
<input type="reset" value="Reset"></p>
</form>
<p></span></p>

Note the two spans. The one named url is for inserting a "select another table" link, while text is where all the generated HTML will be inserted.

Once the form is submitted, the login.asp page runs. This page is discussed in detail in Part 2 of this article.

  • Read Part 2!


  • Article Information
    Article Title: Online Database Editing Program
    Article Author: Richard Chisholm
    Published Date: Monday, February 21, 2000
    Article URL: http://www.4GuysFromRolla.com/webtech/022100-1.shtml


    Copyright 2017 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers