Android Question SqlLite update not permanent.

tremara1

Active Member
Licensed User
Longtime User
B4X:
Sub updateIt
'update record
Dim newNum As String = lblScript.Text
Dim strUpdateName As String = sp1.SelectedItem
Dim strMedUpdateName As String = lblmedname.text
    sqlText = "UPDATE data SET script = '" & newNum & "'"
    sqlText = sqlText & " WHERE name = '" & strUpdateName "'"
    sqlText = sqlText & " AND med = '" & strMedUpdateName & "'"
SQL1.BeginTransaction
        SQL1.ExecNonQuery(sqlText)
SQL1.EndTransaction

pnlAdd.Visible = False
pnlEdit.Visible = False
pnlMed.Visible = True
SelectItAll

End Sub
This update seems to work and displays the new info when queried. If I userclose the info seems to be retained when app restarted but when I close the app from recent apps or reboot the updated info is not retained. If I do inserts of new records they are retained.
Only seems to be since android 4.4 update (Sony xperia ultra 2). Any clues...
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
I think you should commit the update by adding the TransactionSuccessful
B4X:
SQL1.BeginTransaction
 SQL1.ExecNonQuery(sqlText)
 SQL1.TransactionSuccessful   'add this
 SQL1.EndTransaction
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You could use the example as in the "intellisense":
upload_2014-8-9_2-42-31.png


and don't forget to close the db!
 
Upvote 0

tremara1

Active Member
Licensed User
Longtime User
You guys have done it again..........the TransactionSuccessful was what I missed. Thanks.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Yes, but use the Try-Catch structure... I am afraid that TransactionSuccessful declares the transaction successfully completed.
 
Upvote 0
Top