I have a B4XTable where I sometimes need to delete a row. When I Longpress the row in the table it asks me if I'm sure of the deletion.
Once I answer "yes" it deletes the row perfectly.
As can be seen below I deleted tow 6.
Before delete row: After Delete
Row 1 Row 1
Row 2 Row 2
Row 3 Row 3
Row 4 Row 4
Row 5 Row 5
Row 6 Row 7
Row 7 Row 8
Row 8 Row 9
Row 9 Row 10
Row 10
Now if I try and delete any Row Greater than row 7 nothing happens.
If I delete any row from row 5 to row 1 it does delete the row though.
The code is"
Please tell me where the error is to prevent it to delete rows after the previous deleted row?
Once I answer "yes" it deletes the row perfectly.
As can be seen below I deleted tow 6.
Before delete row: After Delete
Row 1 Row 1
Row 2 Row 2
Row 3 Row 3
Row 4 Row 4
Row 5 Row 5
Row 6 Row 7
Row 7 Row 8
Row 8 Row 9
Row 9 Row 10
Row 10
Now if I try and delete any Row Greater than row 7 nothing happens.
If I delete any row from row 5 to row 1 it does delete the row though.
The code is"
B4XTable delete.:
Sub DeleteRow2 (tbl As B4XTable, RowId As Long, DBRowId As Long)
SQL1.ExecNonQuery2("DELETE FROM GroceProd WHERE gid = ?", Array (DBRowId))
tbl.sql1.ExecNonQuery2("DELETE FROM data WHERE rowid = ?", Array (RowId))
Dim page As Int = tbl.CurrentPage
Dim FirstIndex As Int = tbl.FirstRowIndex
tbl.ClearDataView
If FirstIndex + 1 >= tbl.mCurrentCount Then
page = page - 1
End If
tbl.CurrentPage = page
End Sub
Sub B4XTable2_CellLongClicked (ColumnId As String, RowId As Long)
Dim sf As Object = XUI.Msgbox2Async("Are you sure you want to delete this row?", "Deleting a row from your data!", "Yes", "", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = XUI.DialogResponse_Positive Then
DeleteRow2(B4XTable2, RowId, RowId)
End If
Dim Data1 As List
Data1.Initialize
Dim Rs As ResultSet = SQL1.ExecQuery("SELECT gid, gprod, gprice FROM GroceProd")
Do While Rs.NextRow
Dim Row(3) As Object
Row(0) = Rs.GetInt("gid")
Row(1) = Rs.GetString("gprod")
Row(2) = Rs.GetString("gprice")
Data1.Add(Row)
Loop
B4XTable2.SetData(Data1)
Rs.Close
End Sub
Please tell me where the error is to prevent it to delete rows after the previous deleted row?