Android Question SQLite Open, Insert Update Delete test for successful completion

Domingo Garcia

Member
Licensed User
Hello,
How do I test to verify that an Open of an SQLite DB was successful, same for the Insert/Update/Delete commands, the only one that has a result code seems to be Select.

Thanks
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I'm not sure what you mean by "test." The result from a SQL query is dependant upon the query (some queries return nothing, some return success/failure, some the number of rows modified).

If you're looking to see if the command itself failed (i.e. missing file, malformed SQL, etc.) then wrap your command/query in a TRY /CATCH and handle the exception accordingly.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
OK, how do I test for that exception. on the Open DB, INSERT, UPDATE are they all the same?

Hey Domingo: You do something like this;
B4X:
SQL1.BeginTransaction
Try
  'Execute the sql statements or the NON Query statements: DELETE/UPDATE/INSERT.
SQL1.TransactionSuccessful
Catch
   'the transaction will be cancelled
     Log(LastException.Message)
End Try
SQL1.EndTransaction
 
Upvote 0
Top