In ADO (ActiveX Data Objects), the CursorLocation property of a Recordset determines where the cursor that navigates through records is located — either on the client side or the server side. This affects performance, record navigation, and which features are available.
1. Purpose
CursorLocation controls:
-
Whether the Recordset operations (like moving, filtering, sorting) are handled on the client or on the database server.
-
Availability of features like MovePrevious, AbsolutePosition, Filter, and Sort.
2. Syntax
rs.CursorLocation = adUseClient ' Client-side cursor
or
rs.CursorLocation = adUseServer ' Server-side cursor
3. CursorLocation Types
| CursorLocation |
Description |
Advantages |
Limitations |
| adUseClient (Client-side) |
Cursor is managed by ADO on the client machine |
Supports backward navigation, MovePrevious, AbsolutePosition, Filter, Sort, disconnected Recordsets |
Uses more memory on client |
| adUseServer (Server-side, default) |
Cursor is managed by the database server |
Less memory used on client; can handle large datasets efficiently |
Limited navigation (MovePrevious may not work); Filter and Sort may not be available |
4. Example
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
' Use client-side cursor for full navigation
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockOptimistic
rs.Open "SELECT * FROM Employees", conn
rs.MoveLast ' Works because cursor is client-side
rs.AbsolutePosition = 1
rs.Filter = "Department = 'Sales'"
rs.Sort = "Salary DESC"
5. Key Points
-
Client-side cursor (adUseClient) is required for:
-
Server-side cursor (adUseServer) is usually faster for read-only forward-only operations on large datasets.
-
Often combined with CursorType to control navigation and performance.