Table Filter variable with apostrophe

Discussion in 'Questions (Windows Mobile)' started by JamesC, Mar 30, 2008.

  1. JamesC

    JamesC Member Licensed User

    How do I TableFilter using a variable if the variable contains an apostrophe?

    e.g. x="l'ami"

    table1.filter("Name = '" & x & "'") will throw up an error, while it will work for variables that don't contain an apostrophe.


  2. Erel

    Erel Administrator Staff Member Licensed User

    I don't think that it is possible.
    You can try to use Like instead:
    "Name LIKE '*ami'"
  3. JamesC

    JamesC Member Licensed User


    Thanks Erel, that's what I thought. I'll rewrite my filter code to check for apostrophes.

    What do you think - perhaps it would be a good idea to have a filter command that just dealt with variables, as I imagine this is how it is often used? At present, using different syntax for numbers and strings makes it a little more complex - but perhaps that is just my application, which has a one button filter of the selected column by the contents of the selected cell. I need different syntax depending on whether the column holds numbers or strings. Which is not too difficult. But then adding code to look for apostrophes!!!

    Best regards!
  4. Erel

    Erel Administrator Staff Member Licensed User

    If you treat numbers as strings then you can use cString columns instead of cNumbers.
  5. BPak

    BPak Active Member Licensed User

    You could try substituting the ' with an underline _
    in the string and then do the LIKE 'sqlite_'

    In the SQL i Use in C I can use either the Underline or the % as a substitue for any char in the LIKE String. SQLite should be able to use this.
  6. digitaldon37

    digitaldon37 Active Member Licensed User

    Would using double quotes for the query instead of single quotes work?

    table1.filter("Name = " & chr(34) & x & chr(34) & "")
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice