Android Question (SOLVED) Problem with UPDATE-DELETE and WHERE / AND SQL operators

Matteo Granatiero

Active Member
Licensed User
I have a problem joining the DELETE-UPDATE-WHERE-AND operators receiving an error as in the picture
Ho un problema unendo gli operatori UPDATE-WHERE-AND. I do not receive any errors, but the database is not updated (I also checked by extracting the .db file on the pc).
Suggestions?

B4X:
        Dim Query As String
        Query = "UPDATE Rifornimento SET Data = ?, Chilometri = ?, Importo = ?, PrezzoLitro = ?, LitriErogati = ?, Note = ?, Immagine = ? WHERE Targa = 'targaId' AND Chilometri = 'chilometriId' "
        SQL1.ExecQuery2(Query, Array As String(txtDataMod.Text, txtKmMod.Text, txtImportoMod.Text,txtPrezzoMod.Text,litririf, txtNoteMod.Text,nomeimg))
 
Last edited:

Matteo Granatiero

Active Member
Licensed User
I also solved it thanks to the SQL1.ExecNonQuery2. I also had to change the query (WHERE Targa =? AND Kilometers =?) Thanks everyone!šŸ˜‰
B4X:
        Dim Query As String
        Query = "UPDATE Rifornimento SET Data = ?, Chilometri = ?, Importo = ?, PrezzoLitro = ?, LitriErogati = ?, Note = ?, Immagine = ? WHERE Targa = ? AND Chilometri = ? "
        SQL1.ExecNonQuery2(Query, Array As String(txtDataMod.Text, txtKmMod.Text, txtImportoMod.Text,txtPrezzoMod.Text,litririf, txtNoteMod.Text,nomeimmagine,targaId,chilometriId))
 
Upvote 0

Matteo Granatiero

Active Member
Licensed User
This is very easy:
When you update a table, you use SQL1.ExecNonQuery2 NOT SQL1.ExecQuery2
now i have the same problem with the DELETE function

B4X:
Dim query As String
    query = "DELETE FROM Info WHERE Targa = ? AND Chilometri = ?"
    SQL1.ExecNonQuery2(query,Array As String(targaId,chilometriId))
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
now i have the same problem with the DELETE function
The syntax you posted is correct, unless you have a stray space somewhere. I am sure you verified the columns spelling is exact. Sometimes in DELETE you may want to use only one column in the WHERE clause to test to minimize the potential error, then use the other column to test and see which one is the culprit. Of course, you use copies of the database. to test with. If you cannot figure it out and you can post a little project to reproduce it, I am sure many of the forum members would be more than willing to help you.
 
Upvote 0
Top