次の方法で共有


Recordset.BatchSize プロパティ (DAO)

適用先: Access 2013、Office 2013

構文

。Batchsize

expression: Recordset オブジェクトを表す変数。

注釈

BatchSize プロパティを使用すると、一括更新でサーバーにステートメントを送信するときに使用するバッチ サイズを指定できます。 このプロパティの値によって、1 つのコマンド バッファーでサーバーに送信されるステートメントの数が決まります。 既定では、それぞれのバッチで 15 ステートメントがサーバーに送信されます。 このプロパティはいつでも変更できます。 データベース サーバーがステートメントのバッチ処理をサポートしていない場合、このプロパティを 1 に設定すると、それぞれのステートメントを個別に送信できます。

この例では、 BatchSize プロパティおよび UpdateOptions プロパティを使用して、指定した Recordset オブジェクトに対する一括更新の要素を制御します。

Sub BatchSizeX() 
 
 Dim wrkMain As Workspace 
 Dim conMain As Connection 
 Dim rstTemp As Recordset 
 
 Set wrkMain = CreateWorkspace("ODBCWorkspace", _ 
 "admin", "", dbUseODBC) 
 ' This DefaultCursorDriver setting is required for 
 ' batch updating. 
 wrkMain.DefaultCursorDriver = dbUseClientBatchCursor 
 
 ' Note: The DSN referenced below must be configured to 
 ' use Microsoft Windows NT Authentication Mode to 
 ' authorize user access to the Microsoft SQL Server. 
 Set conMain = wrkMain.OpenConnection("Publishers", _ 
 dbDriverNoPrompt, False, _ 
 "ODBC;DATABASE=pubs;DSN=Publishers") 
 
 ' The following locking argument is required for 
 ' batch updating. 
 Set rstTemp = conMain.OpenRecordset( _ 
 "SELECT * FROM roysched", dbOpenDynaset, 0, _ 
 dbOptimisticBatch) 
 
 With rstTemp 
 ' Increase the number of statements sent to the server 
 ' during a single batch update, thereby reducing the 
 ' number of times an update would have to access the 
 ' server. 
 .BatchSize = 25 
 
 ' Change the UpdateOptions property so that the WHERE 
 ' clause of any batched statements going to the server 
 ' will include any updated columns in addition to the 
 ' key column(s). Also, any modifications to records 
 ' will be made by deleting the original record 
 ' and adding a modified version rather than just 
 ' modifying the original record. 
 .UpdateOptions = dbCriteriaModValues + _ 
 dbCriteriaDeleteInsert 
 
 ' Engage in batch updating using the new settings 
 ' above. 
 ' ... 
 
 .Close 
 End With 
 
 conMain.Close 
 wrkMain.Close 
 
End Sub