Android Question SQL problem

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,

I don't understand this: Some insert statements work, some don't. And I get no error messaage, nothing.

How can this be?

B4X:
Dim SQL1 As SQL
...

Dim tg As TGetContacts
Dim ContactList As List
ContactList.Initialize
ContactList.AddAll(tg.GetAllContacts)
...

For iz=0 To ContactList.size-1
     s=ContactList.Get (iz)
     i = s.IndexOf(CRLF)
     DoEvents
     na = addslashes (s.SubString2(0, i))
     nu = addslashes (s.SubString(i + 1))
     nu=nu.Replace (" ","")
     nu=nu.Replace ("-","")
     nu=nu.Replace ("/","")
     nu=nu.Replace ("#","")
     nu=nu.Replace ("*","")
     s = "select AID from contacts where number='" & nu & "'"
     Log (s)
     If Main.SQL1.ExecQuerySingleResult (s)=Null Then
       s="insert into contacts values (Null,'" & na & "','" & nu & "',0,0,'" & jetz & "')"
       Log (s)
       Main.sql1.ExecNonQuery (s)
       ' sometimes this works, sometimes not
     End If
   Next
 

sorex

Expert
Licensed User
Longtime User
is there data with single quotes in it?

you might need to escape them.

add

B4X:
nu=nu.Replace ("'","''")
 
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
no.
This is one of the statements that show no result, I do not find Ivan in the table. But other similar statements work perfectly.
insert into contacts values (Null,'Ivan','+436766450460',0,0,'2016-04-05')
 
Upvote 0
Top