06-12-2017 11:54 AM - edited 06-12-2017 11:55 AM
Hello,
Just have a quick question about the SQL toolkit (v2.3).
Is there a way to lock an ms sql database upon connection?
I'm currently doing the following sequence:
DBConnect()
DBSetDatabase()
DBActivateSQL()
DBFree()
DBDisconnect()
However, when I do a connect, I don't want to have a same application to be able to read the database.
My understanding is that if I create 2 separate executable with the same functions both .exe will be able to access the ms sql database at the same time.
I tried to implement an optimistic concurrency but I don't think it's working.
06-13-2017 02:57 AM
Hi,
The easiest way of blocking access to your changes until they are done is using transactions. A transaction ensure nobody can access data that is changed until the transaction is finished. During a transaction any other information from database is accessible for other applications (even for a second instance of your application).
See functions: DBBeginTran, DBCommit and DBRollback. (http://zone.ni.com/reference/en-XX/help/370502D-01/cvisqlref/cvidbbegintran/) from SQL Toolkit.
Other blocking ways require deep knowledge of MS SQL language.