3.2. Using a SQL Server Express Database

You won't get far in building data-driven Web applications without a database. In this section, you work within the Visual Web Developer environment to create, configure, and enter data in a database table.

3.2.1. Adding a database to the project

This section assumes that you installed SQL Server 2005 Express (or a newer version) on your development machine. You can run the installer again to add options. To add a SQL Server Express database to your Web project, follow these steps:

  1. In Solution Explorer, right-click the App_Data folder (created in the previous section), and then click Add New Item.

  2. In the Add New Item window, select SQL Database.

  3. Change the name of the database to JulieDVD.mdf and then click Add.

    VWD warns you that you should place a database in the special App_Data folder. ASP.NET provides appropriate security permissions for the App_Data folder.

  4. Click Yes to place the database in the App_Data folder.

    The IDE goes to work, generating an empty database.

The Database/Server Explorer window appears in the IDE. Read on to use it.

3.2.2. Adding a table to the database

Databases store data in tables. It's logical, then, that a database without a table isn't very useful.

To add and configure a database table, bring up Database/Server Explorer (ViewDatabase/Server Explorer), right-click the Tables node and, from the context menu, select ...

Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.