From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Toolkit

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.

0 Kudos
Message 1 of 2
(2,414 Views)

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.

0 Kudos
Message 2 of 2
(2,371 Views)