Android Question Strange bug on Insert

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

I read some data from my MSSQL Server and I insert them to SQLite.

I build the insert command in a string.
B4X:
Do While Crsr.NextRow
   TempQrt = "INSERT INTO LOCAL_ESFIItem VALUES (" & "'" & Crsr.GetString("GID") & "', '" & Crsr.GetString("Code") & "', '" & Crsr.GetString("Description") & "', '" & Crsr.GetString("AssemblyType") & "', " & Crsr.GetString("DetailDescription") & ", " & Crsr.GetInt("Inactive") & ", " & Crsr.GetString("fWeightMUGID")  & "'" & ")"
   Log(TempQrt) --> First LOG
   TempQrt = TempQrt.Replace("'null'", "null")
   Log(TempQrt) --> Second LOG
   LocalSQL.ExecNonQuery(TempQrt)
Loop

After reading and writing without any error almost 1500 suddenly....

I get in the first Log the result...
INSERT INTO LOCAL_ESFIItem VALUES ('E8215879-A881-4C1E-A80C-3C0B29967532', '731335', '5 pcs Masonry Drill Bit Set Craft - 49800005', 0, 'null', 'null', 'null')

and in the second log result
INSERT INTO LOCAL_ESFIItem VALUES ('E8215879-A881-4C1E-A80C-3C0B29967532', '731335', 5 pcs Masonry Drill Bit Set Craft - 49800005, 0, null, 'null', 'null')

As you can see the ' are missing from the command on description field there are in the null fields. The bug is on the replace?

Why?

How I can correct it?
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…