Put database insert code in the same block so that transactions work

Both delete and load the the database in the same block so that they
will be rolled back if the operation fails.  Also try to display a
message to the user while the loading occurs.