Again about SQL

Discussion in 'Questions (Windows Mobile)' started by JJM, Jun 6, 2007.

  1. JJM

    JJM Active Member Licensed User


    cmd.CommandText="INSERT INTO " & NomF & " VALUES " & "('" & TextBox3.Text & "','" & TextBox4.Text & "')"

    If TextBox3.text="Hello" I get no error
    but if Textbox3.text="Hello, how are you" I get an error because of the comma and it's the same thing if TextBox contains an apostrophe.
    (idem for Textbox4.text, of course!)

    Could you hepl me ?


  2. maXim

    maXim Active Member Licensed User

    Hi JJM,

    :sign0013: for my english...

    verifies the command string with this syntax:

    "INSERT INTO TableName(FieldName1, FieldName2, ...) VALUES ('FieldValue1', 'FieldValue2', ...)"

    if omitted the fields name (FieldName?): all the values (FieldValue?) must be inserts in sequence and also the type has to correspond...

    Last edited: Jun 6, 2007
  3. JJM

    JJM Active Member Licensed User

    Thank you,

    It's not the syntax of the sentence who's wrong but the content of the column.
    The content seems not to accept coma or/and apostroph. If I replace comma by '-' or by '_' iI get no error.
    Is there an option which one I can use comma?

    Best regards and :sign0085:

  4. dzt

    dzt Active Member Licensed User


    It looks like nothing is wrong about the comma. Onle take care to enclose strings inside apostrophs.

    To solve ' problem add one more next to the first:
    'JJM's app' -> 'JJM''s app'

  5. JJM

    JJM Active Member Licensed User

    Thanks Dimitris,

    The error was with the apostroph. In the cell there were a comma and an apostroph and of course i got an error.

    Thanks again for your help.

    Best regards

    JJ M
  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