Hi guys...
I'm facing an issue for which I created a temporary workaround, but that risks to be ineffective as time goes by...
I have a button that when clicked takes the content of a TextField and adds it to a MySQL DataBase Table using iRDC2, since this is "variant time consuming" I then use a CallSubDelayed method to call a Refresh sub to Query the updated table, because doing it immediately after the insert query retrieves a not-updated recordset... Also, because of this small time gap, I can't query the table for this last entry's index before the refresh sub finishes... So, and since sequencing CallSubDelayed methods seems to not have the desired effect, I am forced to set a timer to allow a timegap large enough for the refresh to take place...
BUT, I fear that once this table grows large, this approach may also fail...
As always... I explained as best I could, but feel free to ask for clearer explanaitions!
I'm facing an issue for which I created a temporary workaround, but that risks to be ineffective as time goes by...
I have a button that when clicked takes the content of a TextField and adds it to a MySQL DataBase Table using iRDC2, since this is "variant time consuming" I then use a CallSubDelayed method to call a Refresh sub to Query the updated table, because doing it immediately after the insert query retrieves a not-updated recordset... Also, because of this small time gap, I can't query the table for this last entry's index before the refresh sub finishes... So, and since sequencing CallSubDelayed methods seems to not have the desired effect, I am forced to set a timer to allow a timegap large enough for the refresh to take place...
BUT, I fear that once this table grows large, this approach may also fail...
As always... I explained as best I could, but feel free to ask for clearer explanaitions!
B4X:
.....
timer0.Initialize("setListviewSelectedItem",500)
.....
Sub Button1_Action 'ADD
Log("button1")
'INSERT INTO `xpto`.`Country` (`CountryName`) VALUES ('France');
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "insert_Country"
cmd.Parameters = Array As Object(TextField1.Text)
reqManager.ExecuteCommand(cmd, "InsertCountry")
' TextArea1.Text = TextArea1.Text & CRLF & $"INSERT INTO `Country` (`CountryName`) VALUES ('${TextField1.Text}')"$
tempstring = TextField1.Text
Log(tempstring)
TextField1.Text = ""
CallSubDelayed(Me,"refresh_Listview")
timer0.Enabled = True
End Sub
Sub setListviewSelectedItem_tick
timer0.Enabled = False
ListView1.SelectedIndex = ListView1.Items.IndexOf(tempstring)
ListView1.ScrollTo(ListView1.Items.IndexOf(tempstring))
ListView1.RequestFocus
End Sub
Sub refresh_Listview
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "select_Country"
reqManager.ExecuteQuery(cmd,0, "selectCountry")
' TextArea1.Text = TextArea1.Text & CRLF & "SELECT CountryName FROM Country"
' TextArea1.SetSelection(TextArea1.Text.Length, TextArea1.Text.Length)
End Sub