Chapter 9 Try It Out Error, page 325
The Looping and Making Decisions Try It Out, Line 5, asks you Save the files and run.
If you get an error (Invalid cast exception ...) on code line:
GoalsFor += Convert.ToInt32(rdr("GoalsFor"))
it is because the database table Fixtures contains a record for the BuyChester United team with NULL values in the goalsfor and goals against fields. (A try-catch block could have caught this.)
To fix this: Use the Database explorer to navigate to the WroxUnited.mdf database tables, right click the Fixtures table and select Show Table Data. When the table displays, you can manually enter non-NULL values. The \End\Chapter09 shows values: GoalsFor = 1 and GoalsAgainst = 2 and you should replace the NULLs with those if you want to exactly duplicate the results shown in Figure 9-8.