Dim strtxt As String = TextBox1.Text
If strtxt.Length = 0 Then
MsgBox("pls type as id")
Return
End If
'Create a connection to the database
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\obice\Desktop\DATATEST\DATATEST\bin\Database1.mdb;")
'provider to be used when working with access database
'cn.Open()
cmd = New OleDbCommand("Select STAFFID From UMP where= '" & TextBox1.Text & "'", cn)
cn.Open()
dr = cmd.ExecuteReader
While dr.Read()
ListBox1.Items.Add(dr(2))
ListBox1.Items.Add(dr(3))
End While
Catch ex As Exception
End Try
dr.Close()
- Add new comment
- 2 views