In the attached code i'm trying to run SQL queries on the fly as a search string is typed in using txtSQL2_KeyPress. It seems that the txtSQL2_KeyPress event doesn't get the latest text that has been typed in - always a cycle behind. Type in 'Area' into the pink text box. Is there a way round this?
You can try using the TextChanged event instead. It will probably be easier:
B4X:
'obj is an Object, TextBox1ChangedEvent is an Event.
Sub App_Start
Form1.Show
obj.New1(false)
obj.FromControl("textbox1")
TextBox1ChangedEvent.New1( obj.Value,"TextChanged")
End Sub
Sub TextBox1ChangedEvent_NewEvent
form1.Text = textbox1.Text
End Sub
I had an error in the code, which didn't close the database connection, but generally speaking is it possible to query the current connection state of the database?
I've also found that when I leave the database connection open for a while in the background and go doing other things on different forms totally unrelated to SQL and then come back to do a query, I get "Database is not open Continue?" error even with line 'DBconnection.Close' commented out.