Assuming you want to write some data to a RFID card and some data to a database. Theoretically the connection to the database might break at any time and the connection between the card and the card reader might break at any time too. Your goal is to design it in a kinda atomic way that you either end up with both or none being written.
Is there any elegant approach to solve this? Any hints are appreciated :)
(I'm using MS SQL Server and the Windows Smart Card Module (Winscard.dll) in case it makes any difference)
Insert a record before you start your update of the RFID card, then update this record when complete. In this way you'll also be able to spot half-completed updates, and act accordingly.
Then have a process which resolves incomplete records after a timeout period has elapsed (either by trying again, or whatever else you want to do).
Do not try to hold open a database transaction while you communicate with your RFID card, as this will: