Application of SQL Server system storage process in VB

Source: Internet
Author: User
Tags resource
server| process

To lock application resources (Sp_getapplock/sp_releaseapplock) as an example:

Sp_getapplock no return parameter (output type), only return value in SP

Lock

Dim cmd as Adodb.command
Set cmd = New adodb.command
Cmd. ActiveConnection = CNN
Cnn. BeginTrans
Cnn. Execute "Use master"
Cmd.commandtype = adCmdStoredProc
Cmd.commandtext = "Sp_getapplock"
The system identification format is: ' "{? = Call Sp_getapplock (?,?,?,?)} "
Cmd. Prepared = True
Cmd. Parameters (1) = name of "Lock name" resource lock
Cmd. Parameters (2) = "Exclusive"
Cmd. Parameters (3) = "Transaction"
Cmd. Parameters (4) = 0 ' to receive the value returned by the return keyword in the SP
Cmd. Execute
MsgBox cmd. Parameters (0) ' Display return value

Unlock:

Dim cmd as Adodb.command
Set cmd = New adodb.command
Cmd. ActiveConnection = CNN
Cmd.commandtype = adCmdStoredProc
Cmd.commandtext = "Sp_releaseapplock"
Cmd. Parameters (1) = "Lock name" Lock resource Name
Cmd. Parameters (2) = "Transaction"
Cmd. Execute
MsgBox cmd. Parameters (0)



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.