I am rather new here and have already a good (I hope so) question.
I work with an access mdb
When I run the program with the following code it gives an error “Nullreference exception unhandled” “the object… is not for an example of an object…” (very free translated but you will surely recognize this)
This is my code:
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
Dim dvFilter As DataView = Nothing
If TypeOf DagverslagDataGridView.DataSource Is DataView Then
dvFilter = CType(DagverslagDataGridView.DataSource, DataView)
ElseIf TypeOf DagverslagDataGridView.DataSource Is DataTable Then
dvFilter = CType(DagverslagDataGridView.DataSource, DataTable).DefaultView
End If
If TextBox5.TextLength > 0 Then
dvFilter.RowFilter = ("select * from Dagverslag WHERE Feit LIKE '*" & TextBox5.Text & "*'")
Else
dvFilter.RowFilter = ""
End If
DagverslagDataGridView.DataSource = dvFilter
End Sub
My question is: What am I doing wrong ?