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:'(

kvprajapati commented: Use code tag please. -1

Recommended Answers

All 2 Replies

Try to use two argument fill method,

Me.adaptertest.Fill(Me.datasetMainForm,"table1")

i have tried it and it doesn t seem to work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.