Problem with a LIKE clause with a "*" inside in VB.Net accessing a DB2/400 table
Posted on 2016-10-07
I get an error with a SQL statement getting data in a DB2/400 database when the WHERE clause contains a LIKE clause where the content of the LIKE includes the star character, "*", and this in a VB.Net application.
When my SELECT statement looks like this:
SELECT ... FROM MyTable WHERE Field1 LIKE 'ABC* %'
i.e. when the content of the like clause includes a star character. The content of the LIKE clause is actually the value of a field from an other table, so I do not control the presence or absence of the star character.
I get the error: "Error in Like operator: the string pattern 'ABC* %' is invalid."
The connection is done over IBM's own ODBC driver for the iSeries.
I *guess* it's because the star character is the wild card character in the Microsoft world, and the ODBC driver gets confused with 2 wild characters, maybe ? This is not an IBM DB2 error message, therefore probably a Microsoft error message.
Has anybody had this combination and knows how to avoid the error ?
Thanks for help on this