error connot display

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()
Submitted byadminon Wed, 09/30/2009 - 22:23

You forgot to include other field in your SQL: Select STAFFID From UMP where= '" & TextBox1.Text & "' This will probably return an error at this line: ListBox1.Items.Add(dr(2)) ListBox1.Items.Add(dr(3))

Add new comment