In this exercise, you will set up the State University Bookstore database using Microsoft SQL Server.


Note  The labs for this course were designed to use a Microsoft SQL Server database. If you do not have Microsoft SQL Server, you can use StateUBookstore.mdb, an Access 97 database located in <install folder>\Labs\Lab02\StateUBookstore Database, to complete most of the lab exercises. If you use the Access database, you may have to adjust some steps and code accordingly.

Start the SQL Server service

  1. On your SQL Server computer, run the SQL Service Manager from the Microsoft SQL Server 6.5 folder on the Start menu.

  2. In the Services list, select MSSQLServer.

  3. Double-click Start/Continue to start the service, and then close the SQL Service Manager.

Register your SQL Server if necessary

  1. Run the SQL Enterprise Manager from the Microsoft SQL Server 6.5 folder on the Start menu.

  2. If your SQL Server is listed in the SQL Enterprise Manager, open it by clicking the plus sign (+) next to the server name.

    – or –

    If your SQL Server is not listed in the SQL Enterprise Manager, you will need to register your server.

    1. On the Server menu, click Register Server.

    2. In the Server box, enter your server name.

    3. Under Login Information, enter the login ID sa and a blank password.

    4. Click Register, and then click Close.

Create the State University Bookstore database device

  1. In the SQL Enterprise Manager, right-click the Database Devices folder, and then click New Device.

  2. Name the new device StateUBookstore.

  3. In the Size (MB) box, type 15.

  4. Click Create Now to create the StateUBookstore database device.

Create the State University Bookstore database

  1. In the SQL Enterprise Manager, right-click the Databases folder, and then click New Database.

  2. Name the new database StateUBookstore.

  3. In the Data Device list, select the StateUBookstore device.

  4. In the Size (MB) box, type 15.

  5. Click Create Now to create the StateUBookstore database.

Create the tables and load the data for the State University Bookstore database

  1. In the SQL Enterprise Manager, on the Tools menu, click SQL Query Tool or click the SQL Query Tool toolbar button.

  2. Select the StateUBookstore database from the DB list.

  3. Click the Load SQL Script toolbar button.

  4. Select StateUBookstore.sql from <install folder> \Labs\Lab02\StateUBookstore Database, and then click Open.

  5. To run the SQL script, click the Execute Query toolbar button.

    This script creates tables and adds data to the tables. The script is complete when the Execute Query toolbar button changes from a black arrow to a green arrow.

Execute the instcat.sql script

  1. In the SQL Query Tool, click the Load SQL Script toolbar button.

  2. Select instcat.sql from <Windows NT folder>\System32, and then click Open.

  3. Click the Execute Query toolbar button.

    The instcat.sql script improves the way Visual Basic uses the OLE DB Provider for SQL Server to communicate with SQL Server. For more details, see the Visual Basic readme file. The script is complete when the Execute Query toolbar button changes from a black arrow to a green arrow.

  4. Close the Query Tool window and then click Yes to confirm that the window should be closed.