Android Question SQLite Exception near "00"

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!


B4X:
        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&")")
 

Espinosa4

Active Member
Licensed User
Try:

B4X:
sSQLViejos.ExecNonQuery2("INSERT INTO ServOrdinarios (" & Campos & ") VALUES(?,?,?,?,?,?,?,?,?,?,?,?)", Array As String(Serv, Tom, Dej, Jor, Lin, Noc, Obs, Cor, Gru, act, Pec, Fec))
Thank very very much indeed LucaMs! It works perfectly!!

Cheers
 

Espinosa4

Active Member
Licensed User
@Espinosa4 : you didn't mention if these are numeric or text field. are the fields starting withT text fields?
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
 

sorex

Expert
Licensed User
cool, you need to encapsulate string in single quotes.

B4X:
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 ;) )
 
Top