Over-the-air (OTA) programming eliminates the need of detaching the sensor nodes and attaching the data transfer cable when updating the sensor software. However, a poorly designed OTA programming system with special environment conditions may lead to version inconsistency problem, which can make sensor applications produce incorrect result and make the sensor network unable to operate. This paper proposes a transaction-based approach to solve the version inconsistency problem of OTA programming. A multi-node OTA programming procedure is modeled as a transaction like database transaction and the programming of each individual node is modeled as a subtransaction. When the update is finished, the system or the manager could commit or abort the transaction according to the result of subtransactions. The commit and abort actions synchronize the software version and thus the version inconsistency problem would never occur. The system is implemented on a ZigBee platform developed by ITRI.