VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > vb >
  • vb教程之锁住数据库中的表

把表达式 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") 

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。


相关教程