sqlite insert null

mc73

Well-Known Member
Licensed User
Longtime User
Trying to copy a table via network from one db to another, I dim field data as strings (since I want to massively select dataDields) so when comes the time to insert a null into my table (I use " " in order to denote the null data, it turns out to be "null" (my guess) instead of null. I'm sure I'm doing something wrong here :) Any idea?

B4X:
For l=0 To allFields.Length -1
If allFields(l)=" " Then 
allFields(l)=Null
End If
Next
updateSQL.ExecNonQuery2 ("INSERT INTO myTable VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object _
           (allFields(1),allFields(2),allFields(3),allFields(4),allFields(5),allFields(6),allFields(7),allFields(8),allFields(9),allFields(10), _
            allFields(11),allFields(12),allFields(13),allFields(14),allFields(15),allFields(16),allFields(17),allFields(18),allFields(19),allFields(20), _
         allFields(21),allFields(22),allFields(23),allFields(24),allFields(25),allFields(26),allFields(27),allFields(28),allFields(29),allFields(30), _
         allFields(31),allFields(32),allFields(33),allFields(34),allFields(35),allFields(36)))
 

Ricky D

Well-Known Member
Licensed User
Longtime User
is allFields dimmed as an array of strings?

I think that would be the issue

If so dim it as an array of Object

regards, Ricky
 
Upvote 0

poseidon

Member
Licensed User
Longtime User
re

grab a FREE copy of
B4X:
http://www.pipiscrew.com/works/sqlite-manager-v1-0/
right click your table, choose generate insert for b4android. use the code

B4X:
Sub ExecuteWithList(SQLStatement As String,lstVALS As List) As Boolean
   Try
      SQL1.ExecNonQuery2(SQLStatement,lstVALS)
      Return True 
   Catch 
      Msgbox(LastException.Message,"ERROR")
      
      Return False
   End Try
End Sub

reply with your result.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Thank you very much, both, for your replies!

Ricky D, your suggestion solved my problem, I knew it had to be my bad coding, thank you.

Poseidon, I liked the freeware linked, though I currently use the firefox extension for managing sqlite, and for the moment it works for me. Your code is good and certainly avoids my rediculous append of that many variables.
 
Upvote 0
Top