Objectives
The objective of this assignment is to have the ability to store the input from a simple form in a database. All database code is provided as part of the assignment.
Assignment
Using the supplied database table and stored procedure (supplied for SQL Server) you must create an input form for a guest book. This will be a simple sign-in that will allow visitors to your web site to leave you their name, email, and a short message. You only need to have a response page that says “Thank you for signing our guest book”. To use the two SQL Server scripts below, simply copy and paste them into a SQL Window within SQL Server and execute them (F5). If you have problems – you may need to issue the command USE [database name] before executing them (and yes – you must fill in the database name field with the name of the database).
CREATE TABLE [ccm].[GuestBook]( [GuestBookEntryID] [int] IDENTITY(1,1) NOT NULL, [GuestBookName] [varchar](200), [GuestBookEntry] [ntext], [GuestbookEmail] [varchar](200), [GuestBookIP] [varchar](20), [GuestBookDate] [datetime] NULL, CONSTRAINT [PK_GuestBook] PRIMARY KEY CLUSTERED ( [GuestBookEntryID] ASC ) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO
CREATE PROCEDURE spInsertGuestbookEntry @GuestBookName varchar(200), @GuestBookEntry ntext, @GuestbookEmail varchar(200), @GuestBookIP varchar(20) AS BEGIN SET NOCOUNT ON; INSERT INTO Guestbook (GuestbookName, GuestBookEntry, GuestbookEmail, GuestBookIP, GuestBookDate) VALUES (@GuestbookName, @GuestBookEntry, @GuestbookEmail, @GuestBookIP, GetDate()) END GO
Information
Chapters 23 and 25 of Deitel text also contain useful information to complete this assignment.
Estimated Completion Time
This assignment can take anywhere from 30 minutes to 15 hours depending on your level of experience.
Supporting Lectures
The Category Code Manager ASPNET Case Study has all the information necessary to complete this assignment.
Another good source is http://www.alphasierrapapa.com/IisDev/Articles/Guestbook/ article and info on creating a Guest book. (Thanks to Lesley Peterson)
For those who have no experience with SQL Server (and are using SQL Server) you will want to watch http://cet4429.pbwiki.com/Getting+Started+with+SQL+Server
And Lelsey comoes through with another site for those using PHP and MySQL http://www.hardcoder.com/scripting/php/guestbook/index.php
Questions and Answers
Outside of handling a few code syntax errors on questions – the most common question is “I’m completely lost” which is usually 3-6 students. Do not panic, unless you waited until the day this assignment was due and then feel free to panic. Here are some simple steps;
1. Install SQL Server
2. Install Visual Studio
3. Watch Getting Start with SQL Server Video
4. Use Scripts supplied to Create Table and Stored Procedure
5. Determine Your Connection String for your database Creating-a-Database-Connection-String
6. Open Visual Studio and Create new web project
7. Follow steps (from Visual Studio Videos) to create pages
External Resources
For some students this will be the most challenging asignment – even though the code is trivial, getting all the programs running will take some time.
Grading Criteria
A working form that stores the information to the database is worth full credit. Partial credit (4 points will be assigned to forms that do not store in the DB).