EDIT: Solution found (Thank you, all):
Original Question:
This is a good one...
The user has built a tableview (and why is there no satisfactory b4xtableview yet?) which has a list of books to be deleted. This code wants to build the MySQL query from the data in the first column of that tableview.
The following snippet of code fails on normal debug execution with
BUT if I but a breakpoint in (at that Log("Cycle...) for example) and then step into each command (looking for my error) it builds the delete query correctly and executes fine.
Dear friends, what has this poor but enthusiastic hobby coder missed?
Dim aryDelete() As Object = tblBookList.Items.Get(0)
Original Question:
This is a good one...
The user has built a tableview (and why is there no satisfactory b4xtableview yet?) which has a list of books to be deleted. This code wants to build the MySQL query from the data in the first column of that tableview.
The following snippet of code fails on normal debug execution with
It appears to fail at "Cycle=0" ie the first time the code encounters it, so its not as though the table is running out of elements...Line 4106
java.lang.ClassCastException: java.base/[Ljava.lang.Object; cannot be cast to java.base/[Ljava.lang.String;
BUT if I but a breakpoint in (at that Log("Cycle...) for example) and then step into each command (looking for my error) it builds the delete query correctly and executes fine.
Dear friends, what has this poor but enthusiastic hobby coder missed?
Failing code:
Private sQuery As String
Private intCount As Int
Private totalRecords As Int = tblBookList.Items.Size
RecordEvent("Size of the tblBookList to be deleted is " & tblBookList.Items.Size)
sQuery="DELETE FROM tblBook WHERE BabcockCode IN ("
For intCount=0 To totalRecords-1
Log("Cycle: " & intCount)
' always select the first record in the table
' which as we delete the previous to be deleted record, will always be 0
Dim aryDelete() As String = tblBookList.Items.Get(0) '<---- this is the flagged error line
sQuery=sQuery & aryDelete(0) & ", "
' remove item from list as it happens
tblBookList.Items.RemoveAt(0)
Next
'trim off last ", "
sQuery=sQuery.SubString2(0, sQuery.Length-2) & ");"
Log("Bulk Book Delete: " & sQuery)
SQL.ExecNonQuery(sQuery)
Last edited: