iOS Question Casting String- to Object-Array

Cadenzo

Active Member
Licensed User
Longtime User
Casting String- To Object array only works in B4A, not B4i:
dim sArr() as String = Regex.Split(";", sLine)
dim oArr() as Object = sArr
SQL1.ExecNonQuery2("INSERT INTO MyTable VALUES (?,?,?)", oArr)

For B4i you can use this small help function:
Sub ConvertArray(arr() As String) As Object()
    Dim iLen As Int = arr.Length
    Dim oArr(iLen) As Object
    For i = 0 To iLen - 1
        oArr(i) = arr(i)
    Next
    Return oArr
End Sub

But is this the way to do?
 

Cadenzo

Active Member
Licensed User
Longtime User
I remember that with some SQL-DB properties (could be INTEGER?) the INSERT or UPDATE worked only with object array, not with string array. So in B4A I can cast the array at once in B4i only field by field?
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
OK, thanks, so I guess, this would be working in B4i and B4A with all TEXT and INTEGER columns in MyTable
B4X:
Dim sArr() as String = Regex.Split(";", sLine) 'sLine like "1234;first text;abcd"
Dim li As List = sArr
SQL1.ExecNonQuery2("INSERT INTO MyTable VALUES (?,?,?)", li)
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
See my answer in post #2. Try it...
Yes, it works with String Array, on both B4i and B4A with SQL tables that have text and integer columns!

In my memory I solved an .ExecNonQuery2 error just with changing the string- into an object array. Only that's why I used it in newer projects. But, as I said, actually the string array works.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…