Loading

error connot display

2 posts / 0 new
Last post
Offline
Joined: 09/29/2009
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()

admin's picture
Offline
Joined: 11/14/2008
re: error connot display

You forgot to include other field in your SQL:

  1. Select STAFFID From UMP where= '" & TextBox1.Text & "'

This will probably return an error at this line:

  1. ListBox1.Items.Add(dr(2))
  2. ListBox1.Items.Add(dr(3))

Pages

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.