brucelim80
Active member
- Joined
- Apr 20, 2006
- Messages
- 35
- Programming Experience
- Beginner
Hi all,
I have the following code for adding item into the checkbox with data extracted from the database.
However, when i removed the line in RED, the while loop show one item less such that the first record is missing. Does anyone know any proper code for this issue.
Thank you
Private Sub Dataentry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConnects As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\136.121.2.1\its helpdesk\calltrack\MDB\ecall.mdb;")
Dim strSelect As New OleDbCommand("SELECT deptcode FROM DeptDB ", myConnects)
myConnects.Open()
Dim reader1 As OleDbDataReader = strSelect.ExecuteReader
With reader1
If .Read Then
departtxt.Items.Add(.Item("deptcode").ToString)
While .Read
departtxt.Items.Add(.Item("deptcode").ToString)
End While
End If
End With
I have the following code for adding item into the checkbox with data extracted from the database.
However, when i removed the line in RED, the while loop show one item less such that the first record is missing. Does anyone know any proper code for this issue.
Thank you
Private Sub Dataentry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConnects As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\136.121.2.1\its helpdesk\calltrack\MDB\ecall.mdb;")
Dim strSelect As New OleDbCommand("SELECT deptcode FROM DeptDB ", myConnects)
myConnects.Open()
Dim reader1 As OleDbDataReader = strSelect.ExecuteReader
With reader1
If .Read Then
departtxt.Items.Add(.Item("deptcode").ToString)
While .Read
departtxt.Items.Add(.Item("deptcode").ToString)
End While
End If
End With