Wrox Programmer Forums
|
Visual Basic 2010 General Discussion For any discussions about Visual Basic 2010 topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2010 General Discussion 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 June 6th, 2013, 09:19 AM
Registered User
 
Join Date: Jun 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default bind to a mdb database

I am working on a project that requires me to bind to a Microsoft Access Database table. I have to rewrite the LoadData subroutine to bind to the hubs.mdb database. This is what is currently in the code...

Public Sub LoadData()
' The following code was moved from the Me.Load Event Handler
' for use in unit testing
'
'Load small sample of airport hubs into Hubs array
Hubs(0).ID = "ATL"
Hubs(0).City = "Atlanta"
Hubs(0).Lat = "33° 38' 22"" N"
Hubs(0).Lon = "84° 25' 41"" W"
Hubs(1).ID = "BOS"
Hubs(1).City = "Boston"
Hubs(1).Lat = "42° 21' 42"" N"
Hubs(1).Lon = "71° 0' 42"" W"
Hubs(2).ID = "CLE"
Hubs(2).City = "Cleveland"
Hubs(2).Lat = "41° 24' 27"" N"
Hubs(2).Lon = "81° 51' 4"" W"
Hubs(3).ID = "SEA"
Hubs(3).City = "Seattle"
Hubs(3).Lat = "47° 26' 56"" N"
Hubs(3).Lon = "122° 18' 33"" W"
'Load ID1ComboBox List
For Each Airport In Hubs
ID1ComboBox.Items.Add(Airport.ID)
Next
'Load ID2ComboBox List
For Each Airport In Hubs
ID2ComboBox.Items.Add(Airport.ID)
Next
'Set default values for Combo boxes
ID1ComboBox.SelectedIndex = 0
ID2ComboBox.SelectedIndex = 1
End Sub

And this is the table in the database.

Index ID City Lat Lon
0 ATL Atlanta "33° 38' 22"" N" "84° 25' 41"" W"
1 BOS Boston "42° 21' 42"" N" "71° 0' 42"" W"
2 CLE Cleveland "41° 24' 27"" N" "81° 51' 4"" W"
3 DCA Washington D.C. "38° 50' 57"" N" "77° 2' 29"" W"
4 DEN Denver "39° 51' 12"" N" "104° 40' 32"" W"
5 DFW Dallas/Fort Worth "32° 53' 53"" N" "97° 2' 27"" W"
6 DTW Detroit "42° 12' 30"" N" "83° 21' 24"" W"
7 HOU Houston "29° 38' 44"" N" "95° 16' 44"" W"
8 JFK New York "40° 38' 39"" N" "73° 46' 56"" W"
9 LAS Las Vegas "36° 4' 48"" N" "115° 9' 12"" W"
10 LAX Los Angeles "34° 3' 59"" N" "118° 7' 28"" W"
11 MIA Miami "25° 47' 39"" N" "80° 17' 8"" W"
12 ORD Chicago "41° 58' 41"" N" "87° 54' 22"" W"
13 SEA Seattle "47° 26' 56"" N" "122° 18' 34"" W"
14 SFO San Francisco "37° 37' 5"" N" "122° 22' 43"" W"
15 STL St. Louis "38° 44' 50"" N" "90° 21' 41"" W"

And finally I have to Modify the hubs array to hold 16 items. Rewrite the LoadData subroutine to fill the hubs array with data from the hubs.mdb dataset.

Any help with this would be greatly appreciated.
 
Old June 7th, 2013, 08:33 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you please have a look at the following link

http://msdn.microsoft.com/en-us/library/ms973824.aspx

Hope it helps

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. How to bind MSCHART to database ocx dextergaisie Pro VB 6 0 May 15th, 2007 06:13 AM
using MDB access database in VWD2005EE tjgrindsted ASP.NET 2.0 Basics 0 January 9th, 2007 08:06 PM
trying to bind a picture box to an access database dups General .NET 0 July 20th, 2006 12:56 AM
Hep me! I want to have a database of Sailor.mdb? nguoiditimda Classic ASP Databases 4 February 6th, 2006 11:56 AM
Can't open .MDB database saxitalis C# 1 November 7th, 2003 04:18 PM





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