So cursors are the beasts that let you move from row to row and maintain the contents of the grid as the user scrolls through the rows. Cursors come in many sizes and colors. Take a look at the Data control property above. The DefaultCursor is always selected - this is the most powerful cursor. It permits the user to scroll forward and backwards in the recordset as well as update and delete records. This is the most expensive (in terms of memory and speed) type of cursor. After all, the cursor has to be prepared for any eventuality. Consequently, this default cursor can actually slow down your application. Why? Because it has to keep track of all of the things we just talked about. This takes time and memory.
With ADO, the understanding of cursors is extremely important. In fact, it is critical in order to get our recordset to do the things we want. We need to open certain ADO recordsets with specific types of cursors - in order to get the
property, for example. Well, every time a new Recordset object is created, a cursor is automatically opened. But before we open a recordset, we can specify the type and location of cursor to use when retrieving our results. The.RecordCount
property allows us to set a cursor as forward-only, static, keyset-driven, or dynamic. Each type of cursor has its pros and cons. In the next chapter we will cover each of these and why they are used. .CursorType
This is very important because the type of cursor we use determines whether a Recordset object can be scrolled forward/backward or updated. The type of cursor also affects who can see changed records. Keep in mind that the most efficient cursor is used by default. This is read forward only. If you only need to read the data, one time, and only move forward, this cursor is for you and there is no need to change the default. But if you need something a bit more robust, you need to bypass the default. Let's summarize the cursor options.