Question Search Function

Kelsen1234

New member
Joined
Jul 22, 2010
Messages
1
Programming Experience
Beginner
Hi i am working on a project using vb.net and i have connected a database to it. I have an CDRecords table within that and now i want to create a search box in vb.net where by if i select the artiste name from a combobox and press a button, i can get access to any record that has the selected artiste name.

Can anyone help me out...
 
It might be the answer for ur query kelsen

TRY THIS CODE BY MAKING SOME CHANGE LIKE TABLE NAME AND DATA ADAPTOR AND LET ME KNOW

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
d = ListBox1.SelectedItem

Try
Dim strsql As String
Dim i1 As Integer
Dim DT As New DataTable


strsql = "select price from items where (artistname= '" & d & "') "

Me.OleDbConnection2.Open()'oledb connection
Me.OleDbDataAdapter1.SelectCommand = New OleDb.OleDbCommand(strsql, Me.OleDbConnection2)
Me.OleDbDataAdapter1.SelectCommand.ExecuteNonQuery()
Me.OleDbConnection2.Close()
DT.Clear()
Me.OleDbDataAdapter1.Fill(DT)

For i1 = 0 To DT.Rows.Count - 1

TextBox1.Text = (DT.Rows.Item(i1)("artistinfo"))'fetching the selected artist info from info table
Next

Catch

MsgBox("THERE ARE SOME KIND OF ERROR")
End Try

End Sub

BYE HAVE NICE DAY
 
Last edited:
Note, copying and pasting a 20-line forum code posting is not a better way to learn data access than following a set of video tutorials from the manufacturer of the programming language youre learning..
 
sorry ,if you find my way awkward,but i just wanna help the guy (kelsen) in any way and i dont have much time to make a video on that ,so plz excuse me once again
 
It would take you less time and ultimately realise a better situation for the person learning, if you would simply point them to the videos Microsoft made. This helps you (less time, better answer), and the OP (good learning resource, answers other questions, better quality and more comprehensive than what you can reasonably provide)
 
Back
Top