A question about database locking

Users questions: I use asp to open the database, such as access or mssql, mysql, etc., to use the database lock. I would like to ask, just lock the table lock is operated, or lock the entire database? I do not know vb, asp in my ask is rs.open method Use of the lock. A total of AdLockReadOnly, AdLockPessimistic, AdLockOptimistic, and AdLockBatchOptimistic four, these four are locked or lock the entire database is In the operating table.
Experts answer: used in the VB MDB database, the lock can be divided into 1. The level of the entire database open exclusively (OpenDatabase the second triple that number is true ExclusiveMode) DimdbAsDat abaseSetdb = OpenDatabase ("f: * vbprg * chart", True) 'exclusively OpenDatabase If successful, there is no other way to share with you the Database2. Lock Table, Level in the third set when the Triple OpenRecordset number dbDenyRead + dbDenyWrite can prevent the others and open the Table, while the use of this TableLock, their number is only the second Triple dbOpenTable Or dbOpenDynaset, and dbOpenDynamic, dbOpenSnapshot so you can not use TableLock as to produce an exclusive rsRecordSet. Setrs = db.OpenRecor dset (TableName, dbOpenTable, dbDenyRead + dbDenyWrite) 3. lockout Page's level, which is divided into a. pessimistic locking 'RS is a reference to RS.LockEdit RecordSet object = True when pessimistic locking, that is, if the next RecordSet object. Edit method is successful, it will be the Record Page where the lock until. Update *. CancelUpdate was unlocked. Under a Fu nctionRecordEdit (recstAsRecordset, Optionalntimes) AsBoolean used in the pessimistic locking, ntime that try to lock the number of times, more than the number after the failure to return False. b. Le Outlook locked RS.LockEdit = False when the next RecordSet object. Edit the method, not Lock the Page, until the next. Update immediately after when the Lock unlock the characteristics of this approach is that in. Edit then if the same Others before a Record has been modified, then we under. Update method will be error, this time with the OnError way, then the next time. Update method, as we want to change the content. There is another FunctionRecordUp date (recstAsRecordset, Optionalntimes) AsBoolean used in optimistic locking, ntime that try to Update the number of times, more than the number after the failure to return False. There will be a sum of a Page More than Record, so PageLock, in the same Page will be under the Record Lock all live, and Access database there is no way to do this and XBase RecordLock different; that there may be a Reco rd more than one Page, when you do not become PageLock Record Lock sum of all living, I think it should be impossible, because the maximum length of a Record is limited, when there is no way more than the establishment of the Table, the Binary * Men o like a lot of information, and other such information are not together. 'Open a table, db: Database where the reference table, rs returns the table name table RecordSet'TableName, ExclusiveMode: whether Exclusive open. PublicFunctionOpenTable (dbAsDatabase, rsAsRecordset, ByValTableNameAsString, ByValExclusiveModeAsBoolean) AsBooleanDimiAsIntegerOnErrorGoToErrHandlerOpenTable = TrueIfExclusiveModeThenSetrs = db.OpenRecordset (TableName, dbOpenTable, dbDenyRead + dbDenyWrite) ElseSetrs = db.OpenRecordset (TableName, dbOpenTable) EndIfExitFunctionErrHandler: OpenTable = FalseEndFunction 'used in the pessimistic locking, ntime said try to lock the number of times, more than the number of returns after the failure of FalsePublicFunctionRecordEdit (recstAsRecordset, Optionalntimes) AsBooleanDimiAsIntegeri = 0IfIsMissing (ntimes) Thenntimes = 5EndIfOnErrorResumeNextDoWhileTrueErr.Clearrecst.EditIfErr.Number 0ThenIfntimes 0ThenIfi ntimesTheni = i +1 ElseRecordEdit = FalseExitDoEndIfEndIfElseRecordEdit = TrueExitDoEndIfLoopEndFunction 'used in optimistic locking , ntime that try to Update the number of times, more than the number after the failure to return FalsePublicFunctionRecordUpdate (recstAsRecordset, Optionalntimes) AsBooleanDimiAsIntegeri = 0IfIsMissing (ntimes) Thenntimes = 5EndIfOnErrorResumeNextDoWhileTrueErr.Clearrecst.UpdateIfErr.Number 0ThenIfntimes 0ThenIfi ntimesTheni = i +1 ElseRecordUpdate = FalseExitDoEndIfEndIfElseRecordUpdate = TrueExitDoEndIfLoopEndFunction the lock
  • This information provided by the users.Thanks!