Open function parameters for Recordset objects

xiaoxiao2021-03-06  44

Open function parameters for Recordset objects

Let's talk about the meaning of the Open function parameters of the RecordSet object, the parameter one is the data table name or SELECT instruction; the parameter 2 is the Connection object, we focus on the meaning of the parameter three and parameters. Parameter 3: Recordset type.

It contains four sets of settings

RECORDSET type setting value

AdopenForwardOnly (= 0) read-only, and current data records can only move down

AdoPenStaqtic (= 3) read-only, current data records are free to move

AdopenKeySet (= 1) readable and written, current data records are free to move

AdoPendynamic (= 2) readable and written, current data records are free to move

Note: The difference between AdoPenKeyset and AdoPendynamic is only in the multiplayer to share the database, if you open the data table in AdopenKeyset mode, you cannot see new data records (unless restarted), if you turn it on in AdoPendynamic mode, then Can see new data records from others

Parameter 4: Lock Type. Contains four settings

Set value of lock type

AdlockReadOnly (= 1) default value to open read-only data records

AdlockPESSIMISTIC (= 2) Pessimism

Adlockoptimistic (= 3) Optimistic lock

Adlockbatchoptimistic (= 40 batches Optimistic lock

AdlockReadonly: STY Nice, is only a data operation that is only available to data on the data without performing a record of the database.

AdlockPESSIMISTIC: It refers to only when any two programs update the same record at the same time, only the only program can be updated. E.g:

RS ("Loginnum") = RS ("Loginnum") 1

Rs.Update

If the model of this mode is used, when the program uses the RS ("Loginnum" = value statement to change the data record, the data record enters the recording lock state.

AdlockOptimistic: It refers to it almost impossible for two programs to update the same record, so it is just temporarily locked data records when data is written to data. E.g:

RS ("Loginnum") = RS ("Loginnum") 1

Rs.Update

That is to say, only when rsupdate is executed, the lock record is started, and the statement is complete, so it is possible to have a program that is updated to data records.

AdlockBatchOptimistic: It is not to write the update result in the process of changing the data record until the UPDATEBATCH function is called to the database, and only the data you want to update at this time. recording. E.g:

While Not Rs.eof

RS ("Loginnum") = RS ("Loginnum") 1

RS ("Applynum") = RS ("Applynum") 1

rs.movenext

Rs.Updatebatch

Wend

Note that if this mode is used, the updated function is UPDATEBATCH instead of Update.

Through the above introduction, when the statement is written: RS.Open SQL, CONN, 1, 1, its true meaning is:

RS.Open SQL, CONN, AdopenkeySet, AdlockReadonlytop

转载请注明原文地址:https://www.9cbs.com/read-75309.html

New Post(0)