InformIT Visual Tutorial 5: Active Server Pages Scripts
After completing this tutorial you should be able to do the following:
-
Write an Active Server Pages insert script that takes the information from an HTML form and stores that information in a database
-
Implement simple error-handling code for your insert script
-
Write an Active Server Pages retrieve script that takes information out of a database and formats a nice display of that information in a user's browser
-
Explain and diagram how HTML forms, Active Server Pages, SQL, and databases work together to create an interactive, database-driven web application
Introduction
We've reached the final tutorial! In the previous tutorial, you learned how to get information from your users via an HTML form (Tutorial 4). Before that, you learned how to create a database (Tutorial 2) and communicate with your database in a special language known as SQL (Tutorial 3). In this final tutorial, we'll cover what we like to call the "keystone" technology—Active Server Pages (ASP) scripts. In a database-driven, interactive web application, ASP scripts perform two key functions: 1) inserting the information from an HTML form into your database; and 2) retrieving information from your database and displaying that information in your user's web browser. The first function uses an ASP insert script; the second function uses an ASP retrieve script. Figure 1 shows how this looks as part of our conceptual diagram.
Figure 1 What we're covering (black) versus what we've covered (gray).
Note: To download a zip containing the source files for this article, click here.
We should point out that you don't have to write your scripts in ASP. There are other scripting languages, such as Perl, Cold Fusion, or PHP. However, ASP is the easiest language to learn and, more importantly, has great database connectivity. If you're writing interactive, database-driven web applications, you can't go wrong using ASP; almost anything you can do in the other scripting languages, you can do with ASP.