Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 Databases by Thearon Willis; ISBN: 9780764588945
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 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 December 5th, 2010, 10:33 PM
Authorized User
 
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 5 Exercise 1 ComboBox not filling

I am working through the book and have tried the solutions code from appendix c for Chapter 5 exercise 1 but the combobox doesn't populate with any data. I'm not getting any errors just no data in the comboBox. Here is the code I used. If someone could look it over and point out any errors I would be greatful
Thanks
Neal
****************
Imports System.Data
Imports System.Data.OleDb
PublicClassForm1
'form level variables
Private strConnectionString AsString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\ProjectTimeTracker.mdb;"
Private objConnection AsOleDbConnection
Private objCommand AsOleDbCommand
Private objDataAdapter AsOleDbDataAdapter
Private objDataTable AsDataTable
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
'initialize the Connection object
objConnection = NewOleDbConnection(strConnectionString)
'initialize the command object
objCommand = NewOleDbCommand("SELECT ProjectID, ProjectName FROM Projects", objConnection)
'initialize the DataAdapter object and set the SelectCommand property
objDataAdapter = NewOleDbDataAdapter
objDataAdapter.SelectCommand = objCommand
'initialize the DataTable object
objDataTable = NewDataTable
'populate the DataTable
objDataAdapter.Fill(objDataTable)
'bind the DataTable to the ComboBox
cboProjects.DataSource = objDataTable
cboProjects.DisplayMember =
"ProjectName"
cboProjects.ValueMember = "ProjectID"
'clean up
objCommand.Dispose()
objCommand =
Nothing
objConnection.Dispose()
objConnection =
Nothing
objDataAdapter.Dispose()
objDataAdapter =
Nothing
objDataTable.Dispose()
objDataTable =
Nothing
EndSub
 
EndClass
 
Old December 6th, 2010, 08:14 PM
Authorized User
 
Join Date: Nov 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok redid the project using exactly the same code but I switched framework from .net 4 to the 2.0 framework and it worked correctly. Is there a difference in the way you do this under the .net 4 framework?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Filling ComboBox from Dataset dcathers C# 9 June 15th, 2013 03:31 AM
Filling a combobox/listbox unmeshraut VB How-To 1 September 21st, 2007 12:08 PM
Filling comboBox from an XML File kuznickic C# 2005 11 August 29th, 2007 01:54 AM
Filling SubForm from ComboBox ayazhoda Access VBA 4 June 5th, 2007 10:56 AM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM





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