Question about API updates to Database

  1. 3 months ago

    David S

    May 11 Pre-Release Testers, Xojo Pro

    I have a button that either adds ("PUT") or updates ("PATCH") a record to a database that I am connected to via an API.

    I am looking for the ID of the record and if not found, adds the record to the database. I am finding that I am seeing two records being added and I believe it might be due to the end-user pushing this button a few times in a row and (I am guessing) that the database is not being updated with the new record fast enough to return the ID number, so a new record is being added twice (or sometimes three times).

    Is this possible? Can a database return two different results a few seconds apart? Or should I be looking for another reason that two records are being added.

  2. Dave S

    May 11 San Diego, California USA

    are you making sure the record is being commited (if not it is in a journal file for a few seconds)

    Second... make sure on the table that the record ID is the Primary Key , and thne 2nd record should then be rejected... since the PK must be unique

  3. Emile S

    May 11 Europe (France, Strasbourg)
    Edited 3 months ago

    @David S another reason that two records are being added

    I had a user who clicked a bunch of time (usually 2, but it could have been 3 or…) until I disabled the Add and Update PushButtons at the end of the code.

    Edit:
    Of course, it is very hard to create a secure application. (a user error secured free application).

  4. David S

    May 11 Pre-Release Testers, Xojo Pro

    I had a user who clicked a bunch of time (usually 2, but it could have been 3 or…) until I disabled the Add and Update PushButtons at the end of the code.

    I was thinking of using a Timer but this should work even better. Thanks.

  5. Emile S

    May 11 Europe (France, Strasbourg)

    If this is the reason. But doing so will cost only minutes. Remember to enable the PushButtons when the user made changes to the TextFields/TextAreas, after a click in Clears the interface / etc.

or Sign Up to reply!