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)