锁住数据库中的表

页面导航:首页 > 软件编程 > vb.net > 锁住数据库中的表

锁住数据库中的表

来源: 作者: 时间:2016-02-05 12:32 【

把表达式 True=False 放到表的 ValidationRule 属性就能锁上。 HardLockTable?实现了该功能。声明Public MyDB As DatabaseDim Dummy As Integer函数Function HardLockTable (ByVal w

 

把表达式 True=False 放到表的 ValidationRule 属性就能锁上。 HardLockTable?实现了该功能。

声明

Public MyDB As Database

Dim Dummy As Integer

函数

Function HardLockTable (ByVal whichAction As String,?ByVal aTable As String) As Integer

On Error GoTo HardLockTableError

HardLockTable = True

Select Case whichAction

Case "Lock"

MyDB.TableDefs(aTable).ValidationRule = "True=False"

MyDB.TableDefs(aTable).ValidationText =?"This table locked via " & ?"ValidationRule on " & Now

Case "UnLock"

MyDB.TableDefs(aTable).ValidationRule = ""

MyDB.TableDefs(aTable).ValidationText = ""

Case "TestThenUnLock"

If MyDB.TableDefs(aTable).ValidationRule = "True=False" Then

MyDB.TableDefs(aTable).ValidationRule = ""

MyDB.TableDefs(aTable).ValidationText = ""

End If

End Select

HardLockTableErrorExit:

subFlushDBEngine

optional, see next suggestion

Exit Function

HardLockTableError:

HardLockTable = False

MsgBox Error$ & " error " & "in HardLockTable trying " & "to " & whichAction & " " & aTable

Resume HardLockTableErrorExit

End Function

使用例子

上锁

Dummy = HardLockTable("Lock", "TestTable")

开锁

Dummy = HardLockTable("UnLock", "TestTable")

 

 

 

Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <