Previous Page
Next Page

Installing and Using the Practice Files

The companion CD inside this book contains the practice files that you'll use as you perform the exercises in the book. By using the practice files, you won't waste time creating files that aren't relevant to the exercise. The files and the step-by-step instructions in the lessons also let you learn by doing, which is an easy and effective way to acquire and remember new skills.

Installing the Practice Files

Follow these steps to install the practice files on your computer's hard disk so that you can use them with the exercises in this book.

  1. Remove the CD from the package inside this book, and insert it into your CD-ROM drive.

    NOTE
    An end user license agreement should open automatically. If this agreement does not appear, open My Computer on the desktop or Start menu, double-click the icon for your CD-ROM drive, and then double-click StartCD.exe.
  2. Review the end user license agreement. If you accept the terms, select the accept option and then click Next.

    A menu will appear with options related to the book.

  3. Click Install Practice Files.

  4. Follow the onscreen instructions.

    The practice files are installed to the following location on your computer:

    My Documents\Microsoft Press\Visual CSharp Step by Step

Configuring SQL Server Express Edition

The exercises in Part V of this book require that you have access to SQL Server Express Edition to create and use the Northwind Traders database. If you are using SQL Server 2005 Express Edition, log in as Administrator on your computer and follow these steps to grant access to the user account that you will be using for performing the exercises in these chapters.

  1. On the Windows Start menu, click All Programs, click Accessories, and then click Command Prompt to open a command prompt window.

  2. In the command prompt window, type the following command:

    sqlcmd –S YourServer\SQLExpress –E

    Replace YourServer with the name of your computer.

    You can find the name of your computer by running the hostname command in the command prompt window, before running the sqlcmd command.

  3. At the 1> prompt, type the following command, including the square brackets, and then press Enter:

    sp_grantlogin [YourServer\UserName]

    Replace YourServer with the name of your computer, and replace UserName with the name of the user account you will be using.

  4. At the 2> prompt, type the following command and then press Enter:

    go

    If you see an error message, ensure you have typed the sp_grantlogin command correctly, including the square brackets.

  5. At the 1> prompt, type the following command, including the square brackets, and then press Enter:

    sp_addsrvrolemember [YourServer\UserName], dbcreator
  6. At the 2> prompt, type the following command and then press Enter:

    go

    If you see an error message, make sure you have typed the sp_addsrvrolemember command correctly, including the square brackets.

  7. At the 1> prompt, type the following command and then press Enter:

    exit
  8. Close the command prompt window.

Using the Practice Files

Each chapter in this book explains when and how to use any practice files for that chapter. When it's time to use a practice file, the book will list the instructions for how to open the file. The chapters are built around scenarios that simulate real programming projects, so you can easily apply the skills you learn to your own work.

For those of you who like to know all the details, here's a list of the Visual C# projects on the practice disk.

Project

Description

Chapter 1

TextHello

This project gets you started. It steps through the creation of a simple program that displays a text-based greeting.

WinFormHello

This project displays the greeting in a window by using Windows Forms.

Chapter 2

PrimitiveDataTypes

This project demonstrates how to declare variables of each of the primitive types, how to assign values to these variables, and how to display their values in a window.

MathsOperators

This program introduces the arithmetic operators (+ – * / %).

Chapter 3

Methods

In this project, you'll re-examine the code in the previous project and investigate how it is structured by using methods.

DailyRate

This project walks you through writing your own methods (both manually and by using a wizard), running the methods, and stepping through the method calls by using the Visual Studio debugger.

Chapter 4

Selection

This project shows how a cascading if statement is used to compare two dates.

switchStatement

This simple program uses a switch statement to convert characters into their XML representations.

Chapter 5

Iteration

This project displays code fragments for each of the different iteration statements and the output that each generates.

whileStatement

This project uses a while statement to read the contents of a source file one line at a time and display each line in a Windows text box.

doStatement

This project uses a do statement to convert a number to its string representation.

Chapter 6

MathsOperators

This project re-examines the MathsOperators project from Chapter 2, “Working with Variables, Operators, and Expressions,” and causes various unhandled exceptions to make the program fail. The try and catch keywords then make the application more robust so that it no longer fails.

Chapter 7

Classes

This project covers the basics of defining your own classes, complete with public constructors, methods, and private fields. It also covers creating class instances by using the new keyword and by using static methods and fields.

Chapter 8

Parameters

This program investigates the difference between value parameters and reference parameters. It demonstrates how to use the ref and out keywords.

Chapter 9

StructsAndEnums

This project uses an enum type to represent the four different suits of a playing card, and then uses a struct type to represent a calendar date.

Chapter 10

Aggregates

This project builds on the previous project by using the ArrayList collection class to group together playing cards in a hand.

Chapter 11

ParamsArrays

This project demonstrates how to use the params keyword to create a single method that can accept any number of int arguments and find and return the one with the smallest value.

Chapter 12

CSharp

This project uses a hierarchy of interfaces and classes to simulate both reading a C# source file and classifying its contents into various kinds of tokens (identifiers, keywords, operators, and so on). As an example of use, it also derives classes from the key interfaces to display the tokens in a rich text box in color syntax.

Chapter 13

UsingStatement

This project revisits a small piece of code from the previous chapter and reveals that it is not exception-safe. It shows you how to make the code exception-safe with a using statement.

Chapter 14

Properties

This project presents a simple Windows application that uses several properties to continually display the size of its main window.

Chapter 15

Indexers

This project uses two indexers: one to look up a person's phone number when given a name, and the other to look up a person's name when given a phone number.

Chapter 16

Delegates

This project displays the time in digital format by using delegate callbacks. The code is then simplified by using events.

Chapter 17

BinaryTree

This project shows you how to use Generics to build a typesafe structure that can contain elements of any type.

BuildTree

This project demonstrates how to use Generics to implement a typesafe method that can take parameters of any type.

Chapter 18

BinaryTree

This project shows you how to implement the generic IEnumerator<T> interface to create an enumerator for the generic BinaryTree class.

IteratorBinaryTree

This project uses an Iterator to generate an enumerator for the generic BinaryTree class.

Chapter 19

Operators

This project builds three structs, called Hour, Minute, and Second, that contain user-defined operators. The code is then simplified by using a conversion operator.

Chapter 20

BellRingers

This project is a Windows Forms application demonstrating basic Windows Forms controls.

Chapter 21

BellRingers

This project is an extension of the application created in Chapter 20, “Introducing Windows Forms,” but with drop-down and pop-up menus added to the user interface.

Chapter 22

CustomerDetails

This project demonstrates how to validate user input, using customer information as an example.

Chapter 23

DisplayProducts

This project shows you how to use Microsoft ADO.NET to connect to the Northwind Traders database, and retrieve information from the Products table. The project uses the Data Source Configuration Wizard to generate a data source to connect to the database, and DataSet, DataTable, and TableAdapter objects to bind the data source to a DataGridView control. The DataGridView control displays the data in a Windows Form.

ReportOrders

This project shows how to access a database by using ADO.NET code rather than by using the components generated by the Data Source Configuration Wizard. The application retrieves information from the Orders table in the Northwind Traders database.

Chapter 24

ProductsMaintenance

This project demonstrates how to use the DataSet, DataTable, and TableAdapter components to update information in a database. The application uses a DataGridView control on a Windows Form and enables the user to modify information in the Products table in the Northwind Traders database.

Chapter 25

HonestJohn

This project creates a simple Microsoft ASP.NET Web site that enables the user to input information about employees working for a fictitious software development company.

Chapter 26

HonestJohn

This project is an extended version of the HonestJohn project from the previous chapter and shows how to validate user input in an ASP.NET Web application.

Chapter 27

Northwind

This project shows how to use Forms-based security for authenticating the user. The application also demonstrates how to use ADO.NET from an ASP.NET Web form, showing how to query and update a database in a scalable manner.

Chapter 28

NorthwindServices

This project implements a Web service, providing remote access across the Internet to data in the Products table in the Northwind Traders database.

ProductInfo

This project shows how to create a Windows application that consumes a Web service. It shows how to invoke the Web methods in the NorthwindServices Web service.

In addition to these projects, several projects have solutions available for the practice exercises. The solutions for each project are included on the CD in the folder for each chapter and are labeled Complete.

Uninstalling the Practice Files

Follow these steps to remove the practice files from your computer.

  1. In Control Panel, open Add Or Remove Programs.

  2. From the Currently Installed Programs list, select Microsoft Visual C# 2005 Step By Step.

  3. Click Remove.

  4. Follow the onscreen instructions to remove the practice files.


Previous Page
Next Page