摘要:ADO Recordset Open
ADO Recordset Open
Rs.Open Source, ActiveConnection, CursorType, LockType, Options
CursorTypeEnum Values
| Constant | Value | Description |
|---|---|---|
| adOpenUnspecified | -1 | Does not specify the type of cursor. |
| adOpenForwardOnly | 0 | Default. Uses a forward-only cursor. Identical to a static cursor, except that you can only scroll forward through records. This improves performance when you need to make only one pass through a Recordset. |
| adOpenKeyset | 1 | Uses a keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your Recordset. Data changes by other users are still visible. |
| adOpenDynamic | 2 | Uses a dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks, if the provider doesn't support them. |
| adOpenStatic | 3 | Uses a static cursor. A static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible. |
LockTypeEnum Values
| Constant | Value | Description |
|---|---|---|
| adLockUnspecified | -1 | Unspecified type of lock. Clones inherits lock type from the original Recordset. |
| adLockReadOnly | 1 | Read-only records |
| adLockPessimistic | 2 | Pessimistic locking, record by record. The provider lock records immediately after editing |
| adLockOptimistic | 3 | Optimistic locking, record by record. The provider lock records only when calling update |
| adLockBatchOptimistic | 4 | Optimistic batch updates. Required for batch update mode |
以上資料來源參考:http://www.w3schools.com/ADO/
以下參考:【topcat姍舞之間的極度凝聚】
語法
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open Source, ActiveConnection, CursorType, LockType, Options
CursorType 選擇性參數:
此 CursorTypeEnum 值決定提供者在開啟 Recordset 時應使用的指標類型。其可以是下列其中一種常數。
常數說明
adOpenForwardOnly(0):開啟一個只支援向下捲動的RecordSet。(預設)
AdOpenKeyset(1):支援向上與向下捲動;可看到其他使用者對資料進行變動。
AdOpenDynamic(2):開啟一個動態資料指標,支援向上與向下捲動;可看見其他使用者修改、刪除、新增的資料。
AdOpenStatic(3):開啟一個靜態資料指標,支援向上與向下捲動;看不見其他使用者對資料進行變動(較適合asp使用)。
LockType 選擇性參數:
此 LockTypeEnum 值決定提供者在開啟 Recordset 時應使用何種鎖定 (同時性)。其可以是下列其中一種常數。
常數說明
adLockReadOnly(1):唯讀,資料無法變更。(預設)
AdLockPessimistic(2):悲觀鎖定,提供者會進行必要的動作以確保能順利編輯資料錄,其方法通常是在編輯時立即在資料源處鎖定資料錄。
AdLockOptimistic(3):樂觀鎖定,提供者使用樂觀性鎖定,當您呼叫 Update 方法時,僅鎖定資料錄。
AdLockBatchOptimistic(4):樂觀批次更新,此為批次更新模式所需,與即時更新模式相反。