954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Search function

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

tripes
Newbie Poster
18 posts since Mar 2009
Reputation Points: 9
Solved Threads: 0
 

Try to use two argument fill method,

Me.adaptertest.Fill(Me.datasetMainForm,"table1")
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

i have tried it and it doesn t seem to work

tripes
Newbie Poster
18 posts since Mar 2009
Reputation Points: 9
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You