Welcome to beginning of a series of posts in which I’ll be showing you how to create a very basic vb.NET guestbook which can be used as a stand-alone Windows application or an integrated application for your website.
Before you ask, I’m doing this in a series because there’s a lot to get through and you’ll likely be scrolling for a long time if I were to put it all in 1 post. In part 1, we’ll be creating and populating the database that will be the data source for the guestbook.
You’ll need a version of Visual Studio or Visual Web Developer for a purely web-related application. If you don’t have either of these, you can get the express tools from Microsoft‘s website. Be warned though, these downloads are pretty big!
Alternatively, you can check out my post on MDSN (search for vb.NET Guestbook) in a little while (I hope to have it out by Xmas). I’ll be posting absolutely all the code there. I’m using Visual Studio 2005
Lets get to it!
The first thing you’ll need to do is create a new database. We’ll be using a SQL Server database, so open your Server Explorer (View – Server Explorer). Under Data Connections, add a new connection.
In the dialog that appears, select SQL Server Express 2005 as the database type and enter the server name (by default, [MachineName]\SQLExpress) and enter “Guestbook” as the database name. We’re going to use Windows authentication, so you can test the connection. If it works, great! Click OK and lets move on.
Now it’s time to add a table to the database, so under Data Connections in your Server Explorer, right-click on the Guestbook database that we just created and click “Add a New Table”. The first row we’re going to add to the table will be our Identifier. Call the first row “PostID” and set it up as the identifier by looking for Identity | Is Identity in the bottom section of the screen. Set it as the Primary Key by right-clicking on the row and selecting “Primary Key”. Add the following rows too:
Username – varchar(50) – No Nulls
Email – varchar(50) – Nulls
URL – varchar(50) – Nulls
Message – text – No Nulls
We’re not allowing Nulls on the Username and Message fields because these are going to be required fields. Lastly, lets populate the table with a test entry. Right-click on the table in Server Explorer and select DataSheet View. If you’re prompted to save, Save the file as UserPosts. In the DataSheet view, fill in one or two test entries. This will help us to make sure that our forms are working properly.
It seems a shame to leave it just hanging there, but I’ll be writing again soon to show you how to create the forms. Stay tuned…