Cadenzo Active Member Licensed User Longtime User May 23, 2020 #1 Code: Copy dim sArr() as String = Regex.Split(";", sLine) dim oArr() as Object = sArr SQL1.ExecNonQuery2("INSERT INTO MyTable VALUES (?,?,?)", oArr) Code: Copy 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?
Code: Copy dim sArr() as String = Regex.Split(";", sLine) dim oArr() as Object = sArr SQL1.ExecNonQuery2("INSERT INTO MyTable VALUES (?,?,?)", oArr) Code: Copy 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?
Erel B4X founder Staff member Licensed User Longtime User May 24, 2020 #2 What happens with: Code: Copy SQL1.ExecNonQuery2("INSERT INTO MyTable VALUES (?,?,?)", sArr) ? Upvote 0
Cadenzo Active Member Licensed User Longtime User May 24, 2020 #3 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
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?
Erel B4X founder Staff member Licensed User Longtime User May 24, 2020 #4 In this case it expects a List. Any type of array can be converted automatically to a list. Upvote 0
Cadenzo Active Member Licensed User Longtime User May 24, 2020 #5 OK, thanks, so I guess, this would be working in B4i and B4A with all TEXT and INTEGER columns in MyTable Code: Copy 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
OK, thanks, so I guess, this would be working in B4i and B4A with all TEXT and INTEGER columns in MyTable Code: Copy 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)
Erel B4X founder Staff member Licensed User Longtime User May 24, 2020 #6 See my answer in post #2. Try it... Upvote 0
Cadenzo Active Member Licensed User Longtime User May 24, 2020 #7 See my answer in post #2. Try it... Click to expand... 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
See my answer in post #2. Try it... Click to expand... 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.