Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2008, 02:16 PM
Authorized User
 
Join Date: Sep 2007
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB Ch9 Try It Out Looping ... p325

I have a problem with this exercise - an error occurs on the following line:
Code:
goalsFor += Convert.ToInt32(rdr("GoalsFor"))
By experimentation I found that if I swapped this line and the following one (goalsAgainst += etc), the error occurred on this line instead. Also if I set a breakpoint on this line and then step through the code, the error occurs after a number of times through the While loop, so I conclude that it's a particular match in the Fixtures table that causes a problem, rather than something to do with the code itself.

Here is the error text:
Code:
System.InvalidCastException was unhandled by user code
  Message="Object cannot be cast from DBNull to other types."

(rest of detail omitted)

I loaded the "End" version of Chapter09 in VWD, and Decisions.aspx ran in the browser without a problem, so I compared the two pages from the "Begin" & "End" folders.

The "End" version is using a PageInitComplete event instead of PageLoad. I can't spot any other differences. However, if I simply change the event in the "Begin" version, it still doesn't work.

If it helps, I will post the code but if you have the book, it's on p325.

Richard
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express
__________________
Richard
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express
 
Old March 7th, 2008, 04:53 AM
Authorized User
 
Join Date: Sep 2007
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Some progress. I opened the Fixtures table in VWD Database Explorer and found that the last record contained NULL for the goalsFor & goalsAgainst values. Using the breakpoint, I confirmed that this was the point were the error occurred, so I changed the values to numeric and re-ran the Debugger. Hey Presto! The result is displayed in the browser without errors.

Has anyone else encountered this issue? Does your Chapter09 Begin copy of WroxUnited.mdf contain Nulls in the Fixtures table?

Richard
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express
 
Old March 7th, 2008, 04:57 AM
Authorized User
 
Join Date: Sep 2007
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Surprise, surprise - the database in the End folder for Chapter09 doesn't contain Nulls in the affected fields.

Richard
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Monthly Calendar Report (Ch9) mruschetti BOOK: Expert Access 2007 Programming ISBN 978-0-470-17402-9 6 May 7th, 2008 11:43 PM
Ch9 charlist.php undefined index grambell23 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 July 7th, 2006 08:39 PM
CH9 - Apache not using custom error page d2nash BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 June 20th, 2006 11:25 AM
Multidimensional array in ch9 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 November 2nd, 2004 04:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.