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
when using the "try and catch exception" it gives me the error "Data type mismatch in critiria expression" when not using it it gives me the error "an unhandled exception of type 'System.data.oledb.oledbexception' occured in system.data.dll"
Help please
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
when using the "try and catch exception" it gives me the error "Data type mismatch in critiria expression" when not using it it gives me the error "an unhandled exception of type 'System.data.oledb.oledbexception' occured in system.data.dll"
Help please