01-08-2020 09:43 PM
Hello,
I have at least two built applications that access the same database. concurrently.
I suspect that since these are two built applications that run independently, there is a likelihood that some times each of these applications may just happen to open identical connection references. and depending on the application that completes a query/fetch action first, the connection may be closed prematurely by one application causing the other which still requires it to go in error. Or perhaps one attempts to open a new connection reference which happens to be identical to an existing connection reference in the second application, and then goes in error.
Can someone please verify if this is possible and if there is a workaround. If the NI applications Engineers can weigh in, that would be great too.
01-09-2020 02:24 AM - edited 01-09-2020 02:26 AM
It depends on the database, and the driver.
The database should support this (Access for instance didn't, although by now it might).
Queries should be wrapped in transactions. So the driver you're using should have "begin transaction", "fail transaction", "close transaction" VIs. This will tread sets of queries as one transaction, and a supporting database will handle concurrent access for you.
EDIT: What you probably have now is a race condition. If two applications read a value, increase it, then write it, you'll only get 1 increment.