This document provides instructions for connecting a Microsoft Visual Basic 2008 Express Edition project to an Access database and populating a list box with student data from a database table. The steps include creating a new Windows Forms project, adding list and button controls, connecting to an Access database file, selecting database tables, and writing code to retrieve and display student records in the list box on button clicks. The code uses a dataset and table adapter to fill the list box with student first and last names from the database.
1 of 14
More Related Content
04 connect-db-tools
1. F F F F F
51282792031 F F
1
Connect Database with Tools
1. Microsoft Visual Basic 2008 Express Edition F F F 塀
Start >>> Microsoft Visual Basic 2008 Express Edition
2. F F F Create Project F F 塀 Open
Project F Create Project F
2. F F F F F
51282792031 F F
2
3. 2 F F New Project F Windows
Forms Application F F F Condbtoots OK F
F
4. F F F F F F F Toolbox Common Controls --> ListBox Click
F F F F F ListBox1
3. F F F F F
51282792031 F F
3
5. F List Toolbox Common Controls --> Button
F 3 Button F
6. Button 1 F F Properties ---> text F &List List
*** F & F F F F F List F F Shift + L
F
4. F F F F F
51282792031 F F
4
7. Button 2 F F &Clear F F E&xit F 6
Properties
F
8. F F F F F Student Microsoft office
access
Data Sources --> Click Add New Data Sources
5. F F F F F
51282792031 F F
5
9. F F F Data Sources Configuration Wizard Database
Next
10. Click > New Connection F F F Add Connection Click
Change
6. F F F F F
51282792031 F F
6
11. F F F F F F Change Data Source F Data Source F Microsoft
Access Database File F Click > OK
12. Click Browse Access
7. F F F F F
51282792031 F F
7
13. F F F Student Open
14. F F F F F F Add Connection F Browse OK
8. F F F F F
51282792031 F F
8
15. F F Data Sources Configuration Wizard F Next
16. F F Microsoft Visual Basic 2008 Express Edition F OK
9. F F F F F
51282792031 F F
9
17. F F Data Sources Configuration Wizard F Next
18. F Table F F F Department Finish
10. F F F F F
51282792031 F F
10
19. F 18 F F Data Sources
20. F F department Click F F Data Sources Configuration
Wizard F F F Table F major student F department
F F F F 18 Finish
11. F F F F F
51282792031 F F
11
21. F Data Sources F F F
F Data Sources F F F
22. F F F F Code F F F F
1 F Code List F Double Click F F F Code
1 2
Option Explicit On
Option Strict On
2 Code List F Code F 7 15 F Code
12. F F F F F
51282792031 F F
12
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim ds As New studentDataSet ' F DataSet F tableAdapter F - F F F
student F DataSet '
Dim ta As New studentDataSetTableAdapters.studentTableAdapter
ta.Fill(ds.student) ' F student F student DataSet'
' F F F student DataSet'
For i As Integer = 0 To ds.student.Count - 1
' F 塀 F firstname F F '
ListBox1.Items.Add(ds.student(i).firstname & " " & ds.student(i).lastname)
'ListBox1.Items.Add(ds.student(i).firstname)
Next
23. F Code F Clear F F F Code
Double Click F F F Code 19
ListBox1.Items.Clear()
13. F F F F F
51282792031 F F
13
24. F Code F Exit F F F Code
Double Click F F F Code 19
Application.Exit()
25. F Code F F F F Run
List Shift + L F 2
14. F F F F F
51282792031 F F
14
26. Clear Shift + C F 2
*** F Exit Shift + x