Problem with "%" character

Discussion in 'Questions (Windows Mobile)' started by francisco cobos, Nov 19, 2007.

  1. francisco cobos

    francisco cobos Member Licensed User

    Hello,
    I'm trying to filter a csv database, but I get an error when the variable "cad" has a % in the string: (cad="something%"), f example:

    Table1.Filter("cara_pcb LIKE '"&cara& "'AND " &campo & " LIKE '" & cad & "'")

    This works well if the strings don't contain any "%" or "[]"
    Is there any other method?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should enclose %, [ and ] characters with [].
    Example: 'something[%]'
     
  3. francisco cobos

    francisco cobos Member Licensed User

    Problem with % character

    I've tried this, but I get the same error, if I don't include this character there is no problem ¿?
    cad="H64 10[%] 100V LDIL10 AVX/NI"
     
  4. francisco cobos

    francisco cobos Member Licensed User

    problem with % character

    I'm sorry Erel, I was worng:
    I have tried again your solution and now is fine,
    Thanks!

    Anyway, is there any solution for not to have to change the data in the data base?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    There is no need to change the database.
    To properly search for a string with % (using Like):
    Code:
    Table1.Filter("cara_pcb LIKE '"&cara& "'AND " &campo & " LIKE '" & StrReplace(cad,"%","[%]") & "'")
     
Loading...