Database : Fill Datagridview with the row which contains the searched value in table ?

  • Thread starter Thread starter Kevin993
  • Start date Start date
K

Kevin993

Guest
I use the code below to search in one of the columns of my table in database :

Dim SearchJob As String = textbox1.Text

Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\_data.mdb;Persist Security Info=False;")
' Use wildcard'
Dim cmd As OleDbCommand = New OleDbCommand("SELECT membercode FROM _members WHERE membercode Like '%" & SearchJob & "%' ", con)
' or Where JobNo='" & SearchJob & "'

con.Open()
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "_members")
DataGridView1.DataSource = myDataSet.Tables("_members").DefaultView


It works fine , but I want to fill my datagridview with all columns of the row that has the searched string . How to do that ?


Thanks

Continue reading...
 
Back
Top