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,527 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,484 Views)