DataView.RowFilter problems

Nik

New member
Joined
Feb 28, 2006
Messages
3
Programming Experience
Beginner
All of these
VB.NET:
objDataView.RowFilter = "gebruiker_id LIKE *" & txtZoekCriteria1.Text & "*"
objDataView.RowFilter = "gebruiker_id LIKE *'" & txtZoekCriteria1.Text & "'*"
objDataView.RowFilter = "gebruiker_id LIKE %" & txtZoekCriteria1.Text & "%"
objDataView.RowFilter = "gebruiker_id LIKE %'" & txtZoekCriteria1.Text & "'%"
Give this
VB.NET:
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in system.data.dll
Additional information: Syntax error: Missing operand before '*' operator.
How come?

grtz

Nik
 
You need to learn to make use of the help system and/or the MSDN library. The first thing you should have done was had a look at the help topic for the RowFilter property. It would have told you to see the topic for DataColumn.Expression for details of leagl syntax. That topic would have told you this:
WILDCARD CHARACTERS
Both the * and % can be used interchangeably for wildcards in a LIKE comparison. If the string in a LIKE clause contains a * or %, those characters should be escaped in brackets ([]). If a bracket is in the clause, the bracket characters should be escaped in brackets (for example [[] or []]). A wildcard is allowed at the beginning and end of a pattern, or at the end of a pattern, or at the beginning of a pattern. For example:
"ItemName LIKE '*product*'"
"ItemName LIKE '*product'"
"ItemName LIKE 'product*'"
Wildcards are not allowed in the middle of a string. For example, 'te*xt' is not allowed.
 
Back
Top