Beginning ASP.NET 1.1 with Visual C# .NET 1002003 [Electronic resources]

Chris Ullman

نسخه متنی -صفحه : 220/ 181
نمايش فراداده

Installing the Database

The quickest and simplest way to obtain a copy of this database is to download and install the appropriate database from the code download section of this book on [ http://www.wrox.com/. ] Access and MSDE are quite different in structure, so the process for installing each of them is also different. Let's look at how to install the Access version of the database first.

Installing the Access Database

Access is a simple database storage format. It's not designed for heavy usage, or for storing large amounts of data. However, for small database projects, it's very easy to use and distribute.

To install this database, obtain a copy of

WroxUnited.mdb from the code download for this book, and save it in the appropriate folder on your hard drive. As long as the path to the

.mdb file is specified correctly in your connection string, you will be able to read data from the database.

There is, however, one adjustment you will need to make if you want to make changes to the database programmatically. Once you have downloaded the database, you need to right-click on the database file and select Properties to get the dialog shown in Figure C-2:

Figure C-2

Ensure that the Read-only checkbox is unchecked, and you will be able to make modifications to the contents of the database.

Installing the MSDE Database

MSDE databases are more tricky to install than Access databases, but since they are based on the more powerful SQL Server database engine, they are much more robust and scalable.

MSDE databases are registered with the MSDE database server. The main database data file has a file extension of

.mdf , and it has a corresponding log file with an extension of

.ldf . To install the database, you need to have copies of the

WroxUnited.mdf and

WroxUnited_log.ldf files from the code download section.

Important

You must have a copy of MSDE/SQL Server installed before you can install the WroxUnited MSDE version of the database. SQL Server is a full-scale product that is available for purchase or as part of some MSDN subscription options. MSDE is a free download from Microsoft and is the same as SQL Server, but with a more restrictive license. For more information, you can consult the Microsoft Web site ([ http://www.microsoft.com ]). Alternately, you can download MSDE from [ http://www.asp.net/msde/default.aspx?tabindex=0&tabid=1. ]

The easiest and most reliable way to install a new MSDE database from these two files is as follows:

Open up Web Matrix and switch to the Data view in the pane at the top right. In here, click the Add Database Connection button, which is the second button from the right in the top panel of buttons (see Figure C-3):

Figure C-3

In the window that appears, create a new MSDE database as shown in Figure C-4:

Figure C-4

A dialog will pop up asking for the name of the database. Click the Create a new database link at the bottom of the dialog as shown in Figure C-5:

Figure C-5

Finally, when prompted, enter WroxUnited as the name for the new database and click OK as shown in Figure C-6:

Figure C-6

You will now see the new empty database appear in the Data pane as in Figure C-7:

Figure C-7

This is where the fun begins – close down Web Matrix. Now, on the bottom right of your screen – your system tray – you will see a SQL Server/MSDE icon with a green arrow next to it (you may have to click the round button with an arrow in it, to unhide the SQL Server icon). Right- click this icon and select MSSQLServer – Stop as shown in Figure C-8:

Figure C-8

Once the service has stopped, open an Explorer window, and navigate to C:\Program Files\Microsoft SQL Server\MSSQL\Data.

Note

This location may be slightly different on your system. If, for example, you are running a named instance of SQL Server, you will need to navigate to the

MSSQL$InstanceName directory.

In this folder, you need to replace the two WroxUnited files (

WroxUnited.mdf and

WroxUnited_log.ldf ) with the files available in the code download as shown in Figure C-9:

Figure C-9

Once you have done this, restart your SQL Server (again, by right-clicking on the icon in the System Tray), and then reopen Web Matrix. Note that it may take a couple of moments for your SQL Server to restart completely (hover your mouse over the icon in the System Tray for the exact status of the service – once it says Running - \\MachineName - MSSQLServer, you know that the service has fully restarted.

Expand the (local).WroxUnited node in the Data pane in Web Matrix, and the tables should have been imported successfully as shown in Figure C-10:

Figure C-10