Android Question SQLite Exception near "00"

Espinosa4

Active Member
Licensed User
Longtime 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
Longtime 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
 
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime 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
 
Upvote 0

sorex

Expert
Licensed User
Longtime 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 ;) )
 
Upvote 0
Top