Visual Basic Concepts
Using the OpenResultset Method
No matter which type of query you execute, or which type of result set you create, you must use the OpenResultset method to build an rdoResultset to fetch and navigate through the data rows. The connection and specific cursor type used to create the rdoResultset depends on the properties of the object referenced with the OpenResultset method. For example, if you execute the OpenResultset against the rdoQuery object, RDO uses the connection specified in its ActiveConnection property and the cursor type specified in its CursorDriver property.
The OpenResultset method accepts the following arguments:
- When you use the OpenResultset method with an rdoConnection object, you must specify the name argument — basically the name argument string specifies an SQL query. When you use OpenResultset against an rdoQuery object, the SQL statement is drawn from the rdoQuery object's SQL property so the name argument is not needed. When OpenResultset is used against the rdoTable object, the query is assumed to include all rows from the specified table. If your SQL query needs to include parameters, see "Creating RDO Parameter Queries" later in this chapter for more information about choosing the right SQL syntax for parameter queries.
- The type argument specifies the type of cursor — unless you have disabled cursor creation on this connection by specifying rdUseNone for the CursorDriver property. If you do not indicate a cursor type, rdOpenForwardOnly is assumed. The type argument can also specify keyset, dynamic, static, or forward-only cursor types.
Note Not all cursor libraries are capable of implementing all cursor types. For example, the ODBC client-side cursor library (rdUseODBC) is incapable of creating keyset or dynamic cursors. When a driver is incapable of creating a cursor, the driver generally uses a fall-back strategy that selects another cursor that it is capable of creating.
- The locktype argument specifies the type of locking used to support concurrency. Generally, this option determines how and when pages and rows are locked by the remote server. For example, using the locktype argument, you can select several types of optimistic locking, one type of pessimistic locking, or no locking at all, as when you select rdConcurReadOnly (the default). For more information, see "OpenResultset Method" in the Language Reference".
- The options argument specifies if the query should be executed asynchronously and the ODBC function used to execute the query. By default, the query is executed synchronously and the SQLPrepare and SQLExecute API functions are used.
Choosing a Cursor Type
Using arguments of the OpenResultset method or properties of the rdoQuery object, you can specify the type of cursor (if any) and other attributes of the rdoResultset object. However, in many cases, cursors are not the best way to retrieve data as they negatively affect performance and resource utilization.
For More Information See "OpenResultset Method," "Type Property," and "SQL Property" in the Language Reference".