none
Using LIKE for search RRS feed

  • Question

  • Hi,

     

    Is there anyway for searcing like we do in database query using Like keyword or using % sign. I got text file and when user enter product code like P , Pr,Prd or Prdc etc so I want to get all the matching product from the text file and display them.

    Thanks

     

     

    Thursday, November 29, 2007 9:47 AM

Answers

  • How about reading line by line from the text file (using StreamReader.ReadLine) and using String.IndexOf for the search (or regular expressions if you need to support more complex searches)?

     

     

     

    Thursday, November 29, 2007 9:50 AM
  • There are no classes or methods as part of the framework to do the LIKE search as you do in the databases.  You need to do the custom implementation.

     

    You can load the the file into string or string builder and do the search by using

     

    string s;

    s.StartsWith(<Parameters>)

    Thursday, November 29, 2007 9:55 AM

All replies

  • How about reading line by line from the text file (using StreamReader.ReadLine) and using String.IndexOf for the search (or regular expressions if you need to support more complex searches)?

     

     

     

    Thursday, November 29, 2007 9:50 AM
  • There are no classes or methods as part of the framework to do the LIKE search as you do in the databases.  You need to do the custom implementation.

     

    You can load the the file into string or string builder and do the search by using

     

    string s;

    s.StartsWith(<Parameters>)

    Thursday, November 29, 2007 9:55 AM
  • You could use a dataset and the select methode, or a regular expression.
    Thursday, November 29, 2007 10:47 AM
  • Hi,

    This sounds like a good job for regular expressions.

    J
    Friday, November 30, 2007 6:09 AM