Android Question SQLite Exception near "00"

Discussion in 'Android Questions' started by Espinosa4, Jun 17, 2015.

  1. Espinosa4

    Espinosa4 Active Member Licensed User

    Hi!

    I need to insert in the same record differents values. some of them are null values. The programa give me a syntax error (Code1).

    Can you help me please?
    Thank you!


    Code:
    Campos = "NumServicio,TToma,TDeje,TJornada,SLinea,TNocturnas,SObservaciones,SCorrespondencia,Grupo,Actualizado,Peculiar,Fecha"
            sSQLViejos.ExecNonQuery(
    "INSERT INTO ServOrdinarios ("&Campos&") VALUES("&Serv&","&Tom&","&Dej&","&Jor&","&Lin&","&Noc&","&Obs&","&Cor&","&Gru&","&act&","&Pec&","&Fec&")")
     
  2. LucaMs

    LucaMs Expert Licensed User

    Try:

    Code:
    sSQLViejos.ExecNonQuery2("INSERT INTO ServOrdinarios (" & Campos & ") VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"Array As String(Serv, Tom, Dej, Jor, Lin, Noc, Obs, Cor, Gru, act, Pec, Fec))
     
  3. sorex

    sorex Expert Licensed User

    @Espinosa4 : you didn't mention if these are numeric or text field. are the fields starting withT text fields?
     
    Espinosa4 likes this.
  4. LucaMs

    LucaMs Expert Licensed User

    and the field starting with S are... string? ;)
     
    Espinosa4 likes this.
  5. Espinosa4

    Espinosa4 Active Member Licensed User

    Thank very very much indeed LucaMs! It works perfectly!!

    Cheers
     
    LucaMs likes this.
  6. Espinosa4

    Espinosa4 Active Member Licensed User

    Yessss. :D
     
  7. Espinosa4

    Espinosa4 Active Member Licensed User

    Hi sorex,
    All are string but in those cases where I need to know speedy what I was stored, the field starts with S for string, t for time, etc...

    The problem is the null values. But LucaMs resolved my problem.

    Cheers
     
  8. sorex

    sorex Expert Licensed User

    cool, you need to encapsulate string in single quotes.

    Code:
    sSQLViejos.ExecNonQuery("INSERT INTO ServOrdinarios ("&Campos&") VALUES("&Serv&",'"&Tom&"','"&Dej&"','"&Jor&"',"&Lin&","&Noc&","&Obs&","&Cor&","&Gru&","&act&","&Pec&","&Fec&")")
    (I didn't change all of them so copy pasting might still give errors ;) )
     
    Espinosa4 likes this.
  9. LucaMs

    LucaMs Expert Licensed User

    ExecNonQuery2 solve this problem (and in this way you do not have to fight with the quotes)
     
    mangojack and Espinosa4 like this.
  10. sorex

    sorex Expert Licensed User

    I know but I prefer the other method for debugging reasons.
     
Loading...