How i manage nil or null values in Xojo.Core.Dictionary

Dim records() As Auto = dict.Value(“records”)
Dim values() As Auto
Dim str,str1 As Text
Dim v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,er As Text
Dim i1 As Integer

For Each values In records

  v1=  values(0)    <<<< I have error in this values when nil or null (how i do manage the error )
  v2= values(1)
  v3= values(2)
  v4= values(3)
  v5= values(4)
  v6= values(5)
  //v7= values(6)
  v8= values(7)
  v9= values(8)
  v10= values(9)
  Var sql As text = "INSERT INTO Socios (DataSocioNum,DataNombre,DataLocate,DataeMail,DataCellphone,DataActivo) VALUES ('"+ v1 + "','"+ v2 + "', '" + v3 + "', '" + v4 + "','" +v5 + "','" + v6 + "')"
Catch e As IOException
  //ErrorLabel.Text = e.Reason
  er= e.Reason
End Try

for i1=0 to 100


Catch e As IOException
End Try

with PreparedStatement in API<2

here you have different types

You can’t assign null to a Text type. Wrap it in an IF statement and assign “” if null.

If your dict.value is nil and your field can manage it you should use null in your sql string.
If your field can’t accept null use, as @Kem Tekinay suggested, an empty string

In any case I don’t understand why you are building your sql string in that way, since on iOS you have the automatic prepared statement like you have now on API2


Var sql As text = "INSERT INTO Socios (DataSocioNum, DataNombre, DataLocate, DataeMail, DataCellphone, DataActivo) VALUES (?, ?, ?, ?, ?, ?) var v() as auto v.addRow values(0) //you know what you are doing here... .... v.addRow values(4) //you have defined 5 field and values has 13 items... so following your example I take the first 5 App.DBConn.SQLExecute sql, v //now check for errors...