i have a search function in my program in order to find records from an access database... all the other functions add/edit/delete are working just fine... this is my code for search function: Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
Try
Me.datasetMainForm.Clear()
If Me.txtSearch.Text = "" Then
Me.OleDbSelectCommand2.CommandText = "SELECT*" & _
" FROM test"
Me.OleDbSelectCommand2.Connection = Me.connectionMainForm
Me.adaptertest.Fill(Me.datasetMainForm)
Me.grdMainForm.Refresh()
Else
Me.OleDbSelectCommand2.CommandText = "SELECT*" & _
"FROM test" & _
" WHERE(test.ID='" & Me.txtSearch.Text & "')"
Me.OleDbSelectCommand2.Connection = Me.connectionMainForm
Me.adaptertest.Fill(Me.datasetMainForm)'''''''''Here it gives me error Me.grdMainForm.Refresh()
End If

Catch ex As Exception
MsgBox(ex.ToString)
End Try


If Me.datasetMainForm.test.Rows.Count = 0 Then
MsgBox("The color doesn't exist. Empty the search box and click Search")
End If

End Sub


Help please:'(

Comments
Use code tag please.
This article has been dead for over six months. Start a new discussion instead.