The AVBAsk application that was started earlier will do some validation checking on the data entered into the server controls and send a message via email. But it would be very nice if it also kept track of emails sent. That's a job for a database.
To make sure that you had SQL Server 2005 Express (SSE from now on) installed and working, a test database was added to a website in part 2 of this tutorial, SQL Server and ASP.NET. If you have any trouble here, you might want to read through part 2 again. In addition, the application we're building was created in parts 3 and 4. If you don't have that website, you can go through those to create the base application that is being updated here.
Using the AVBAsk website that was last coded in part 4 and using the same methods explained in part 2, add a SSE database to the website:
Database name: AVBQuestions.mdf
Table name: AVBQuestion
Columns:
AVBQuestionKey
int
SetPrimaryKey
AVBQuestionFrom
nvarchar(50)
AVBQuestionSubject
nvarchar(50)
AVBQuestionMessage
nvarchar(MAX)
AVBQuestionDate
datetime
Uncheck all of the Allow Nulls checkboxes except AVBQuestionMessage.
In part 2 of the tutorial, we used a uniqueidentifier as the key type. But a 128 bit GUID is really too much for our application since we really only need a key that will identify each row of the table. So this time, use a type int as the key and change Is Identity to Yes in the Column Properties for AVBQuestionKey. The starting value (Identity Seed) and the increment (Identity Increment) should change to their default value of 1 automatically. Identities are often used as keys for tables. SSE will guarantee that a new value that hasn't been used before will be used whenever a new row is inserted into the database. In fact, you will find that you can't enter data into the column value manually.
The completed database is shown below:
--------
Click Here to display the illustration
Click the Back button on your browser to return
--------

