首页 > 学院 > 开发设计 > 正文

锁住数据库中的表

2019-11-18 17:35:31
字体:
来源:转载
供稿:网友
把表达式True=False放到表的ValidationRule属性就能锁上。HardLockTable?实现了该功能。
声明
PublicMyDBAsDatabase
DimDummyAsInteger
函数
FunctionHardLockTable(ByValwhichActionAsString,?ByValaTableAsString)AsInteger
OnErrorGoToHardLockTableError
HardLockTable=True
SelectCasewhichAction
Case"Lock"
MyDB.TableDefs(aTable).ValidationRule="True=False"
MyDB.TableDefs(aTable).ValidationText=?"Thistablelockedvia"&?"ValidationRuleon"&Now
Case"UnLock"
MyDB.TableDefs(aTable).ValidationRule=""
MyDB.TableDefs(aTable).ValidationText=""
Case"TestThenUnLock"
IfMyDB.TableDefs(aTable).ValidationRule="True=False"Then
MyDB.TableDefs(aTable).ValidationRule=""
MyDB.TableDefs(aTable).ValidationText=""
EndIf
EndSelect
HardLockTableErrorExit:
'subFlushDBEngine
'optional,seenextsuggestion
ExitFunction
HardLockTableError:
HardLockTable=False
MsgBoxError$&"error"&"inHardLockTabletrying"&"to"&whichAction&""&aTable
ResumeHardLockTableErrorExit
EndFunction
使用例子
'上锁
Dummy=HardLockTable("Lock","TestTable")
'开锁
Dummy=HardLockTable("UnLock","TestTable")->


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表