Working With Databases: Overview of Task Sequence
Working With Databases: Overview of Task Sequence
NET Guide
Wo r k i n g w i t h D a t a b a s e s
Initial Set-up
Imports System.Data.Oledb
EG:
Dim objDA As OleDbDataAdapter
Dim objDS As New Data.DataSet()
Dim objCB As OleDbCommandBuilder
Page 1 of 3
SEB’s VB.NET Guide
•objDS and ObjCB are variables previously declared to store required data components
objDA.Fill(objDS, “Data”)
•Using the Fill property of objDA the dataset is filled with the contents of the table
•Data refers to the database table.
Page 2 of 3
SEB’s VB.NET Guide
With objDS.Tables(0)
For lintRecs = 0 To (.Rows.Count – 1)
gbxNames.Controls(lintRecs).Text = _
.Rows(lintRecs).Item(“Name”).ToString
gbxScores.Controls(lintRecs).Text = _
.Rows(lintRecs).Item(“Score”).ToString
Next
End With
Note:
This is the same as the following statement without the WITH:
•A For loop is being used here to loop through the records in the table
•objDS.Tables(0).Rows.Count is the number of records in the data table
•lintRecs is a local integer variable used to count through the loop
•gbxNames and gbxScores are both group boxes containing a series of labels
The first time through the loop, the first label in the group box would be
referenced:
gbxNames.Controls(0).Text = ….
If the name of the first label was lblTopName,
the above statement would be the same as:
lblTopName.Text = …
Names Scores
Tom 988
Billy 972
Jo 963
Page 3 of 3