hi Alls,
I really need your help regarding this method, Actually i need to create one search box using textbox and the result will display on listbox.
I have textbox1 as inputbox, button1 as search button , listbox1 to display the value , Database1.mdb as my database.
Can u guide me to this?...i really stuck on it....thank you
I'm already thry this code,but the result appear all the name,it not searching by id.....how to do that bro?....pls...
"Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Create a connection to the database
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim Sql As String
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Database1.mdb;")
'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; _Data Source=D:\Database1.mdb;")
'provider to be used when working with access database
'cn.Open()
cmd = New OleDbCommand("SELECT * from UMP WHERE ", cn)
cn.Open()
dr = cmd.ExecuteReader
While dr.Read()
ListBox1.Items.Add(dr(2))
'TextBox1.Text = dr(2)
'TextBox2.Text = dr(1)
'TextBox3.Text = dr(2)
' loading data into TextBoxes by column index
End While
Catch ex As Exception
End Try
'dr.Close()
cn.Close()
End Sub