Tuesday, May 3, 2011

sql query for string contains in C#

how to write sql query to do String contains operation.?

Consider,

string strTest = "Hash.System.Data.DataSet has.ds";
string str1 = "Hash.System.Data.DataSet has(System.Collections.Hashtable, Int32).ds";
string str2 = "Hash.System.Data.DataSet has(System.Collections.Hashtable, System.Collections.Hashtable).ds";

Here 1)if i compare strTest with str1 it should return true. 2)if i compare strTest with str2 it should return true.

i.e i can ignore the part of string which is enclosed within '(' and ')'.

edit: i'm trying to access MS access table using C# and need to check such conditions.

i need to check everything in 'strTest' excluding the part of string contained in brackets with str1 and str2.

str1 and str2 are entries in MS access table.

myCommand1.CommandText = "SELECT TableName FROM HashTableConfig WHERE ItemIdentity LIKE '" + strTest + "'";

This is the query where i should do changes so that it satisfies condition 1 and 2. ItemIdentity can have values like str1 and str2.

From stackoverflow
  • field LIKE 'Hash.System.Data.DataSet has(%).ds'
    

0 comments:

Post a Comment