The first thing you'll need is a database. Use Access to create this database; it consists of a few simple fields in the tbl_master table: • EmployeeID • FirstName • LastName • Location
Create this table in Access: (Safer, download it from My Subjects>Sample Database)
|tbl_master |
|EmployeeID |FirstName |LastName |Location |
|1 |Green |Frogg |Somerville |
|2 |Kay |Park |Kalinga |
|3 |Rover |Dog |Albany |
|5 |Gabby |Kase |England |
|6 |Neil |Furman |England |
|9 |Zaza |Gabor |Goonville |
|11 |BeBe |Gabor |Loonville |
|19 |Rebecca |Black |Mars |
| | | | |
Save to D:\My Documents (not a subdirectory) as sample.mdb. Close Access.
Part 1
Open a new Windows application in VB.Net. You will be creating a simple Form for navigating through the records in the table.
Start by placing three labels, three textboxes, and four buttons on a form as shown in the following figure. Name the textboxes txtFirstName, txtLastName, and txtLocation. The buttons should be self explanatory as well: btnFirst, btnPrevious, btnNext, and btnLast.
[pic]
Double click on the Form. Now you can begin the coding. Import the System.Data.OleDb namespace.
Imports System.Data.OleDb right at the top!
Declare a dataset at the class level, under Public Class Form1
Dim ds As New DataSet()
In the Form's Load event, fill the dataset. To do this, create a DataAdapter and use its Fill() method to fill up the dataset.
Dim conn As New OleDbConnection()