Wrox Programmer Forums
|
BOOK: Wrox's Visual Basic 2005 Express Edition Starter Kit ISBN: 978-0-7645-9573-8
This is the forum to discuss the Wrox book Wrox's Visual Basic 2005 Express Edition Starter Kit by Andrew Parsons; ISBN: 9780764595738
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Wrox's Visual Basic 2005 Express Edition Starter Kit ISBN: 978-0-7645-9573-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 May 10th, 2006, 04:20 PM
Registered User
 
Join Date: May 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 7 Problems

I am in the Try It Out that begins on page 129. When I try to complete step 5, my code looks like this:

Private Sub LoadListBox()
        Dim PersonListAdapter As New _PO_DataDataSetTableAdapters.PersonTableAdapter
        Dim PersonListTable As New _PO_DataDataSet.PersonDataTable
        PersonListAdapter.Fill(PersonListTable)
        With lstPersons
            .Items.Clear()
            .DisplayMember = "DisplayName"
            For Each CurrentRow As _PO_DataDataSet.PersonRow In PersonListTable.Rows
                Dim CurrentPerson As New Person(CurrentRow.NameFirst, CurrentRow.NameLast)
                CurrentPerson.ID = CurrentRow.ID
                .Items.Add(CurrentPerson)
            Next
        End With
    End Sub

I am a little unsure, but I believe that is exactly what the book instructs me to do. When I try to run the program, clicking the "Show List" button produces the lstPersons panel, but it is empty, and then VB errors out with this message:

"Items collection cannot be modified when the DataSource property is set."

The offending line of code is ".Items.Clear()", but even when I delete that line, I get the same error message for ".Items.Add(CurrentPerson)". It seems like declaring PersonListAdapter and PersonListTable in the same subroutine is causing this problem, but from the book, I don't know where that bit of code goes.

Please help!!!

 
Old May 13th, 2006, 09:25 AM
Wrox Author
 
Join Date: Jan 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you do everything in Step 1 of that Try It Out?

The errors you're describing indicate that your DataSource property is still set, but the step says to reset the DataSource property to None as stated in the following paragraph:

Return to the Personal Organizer project you’ve been working on in this chapter. Because you’re going to do everything in code, open the PersonList.vb user control in Design view and select the lstPersons component. Locate the DataSource property and change it to None so that it no longer uses the BindingSource object to retrieve information from the database.

Hope that helps!
Andrew






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with chapter 1 macuser BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 2 April 2nd, 2009 12:39 PM
Problems with Example in Chapter 6 elly BOOK: Professional Crystal Reports for VS.NET 0 March 31st, 2008 03:39 PM
Yet more Chapter 4 problems Putter BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 March 28th, 2007 11:37 PM





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