如何锁定这张表
Public Function GetNextID(ByVal LicenseID As Long, ByVal VolumeID As Long, ByVal IDName As String, Optional ByVal StepNumber As Long = 1) As Long
Dim rs As ADODB.Recordset
Dim oCnn As ADODB.Connection
Dim sSql As String
80 On Error GoTo ErrHnd
81 Set rs = New ADODB.Recordset
82 Set oCnn = New ADODB.Connection
84 sSql = "Select IDValue From NextID Where IDName='" & IDName & "'"
85 rs.Open sSql, "FILEDSN=ODAdmin"
87 If rs.EOF = False Then
88 GetNextID = rs!IDValue
89 sSql = "Update NextID Set IDValue=" & (GetNextID + StepNumber) & " Where IDName='" & IDName & "'"
90 Else
91 sSql = "Insert NextID (IDName,IDValue) Values ('" & IDName & "'," & StepNumber & ")"
End If
94 oCnn.Open "FILEDSN=ODAdmin"
95 oCnn.Execute sSql
97 GetObjectContext.SetComplete
98 GetNextID = GetNextID + StepNumber
99 Set rs = Nothing
100 Set oCnn = Nothing
101 Exit Function
ErrHnd:
103 GetObjectContext.SetAbort
104 GetNextID = -1
105 Set rs = Nothing
106 Set oCnn = Nothing
End Function
执行到95行时NextID表被锁定,但我想在执行到85行时锁定NextID表,解决并发的问题,
请问各位有什么办法?