MDAC 2.5 SDK - Technical Articles


 

Optimizations

The following features are designed to improve upon the performance and efficiency of earlier versions of MDAC.

Executing Commands in ADO Without Returned Recordsets

ADO includes options to optimize how commands are executed: For example, to remove the overhead of asking for a rowset on non–row returning commands, you can specify the adExecuteNoRecords option when executing a command. The adCmdTableDirect option forces ADO to use IOpenRowset rather than attempting to open the rowset by building and executing a Command object. Depending on the environment, activating this feature can improve performance and reduce memory overhead for non–row returning commands.

To turn on this feature, add the value of adExecuteNoRecords to the value being passed to the Options parameter, as shown in the following example. (adExecuteNoRecords works only with adCmdStoredProc and adCmdText command types. The other types, by definition, should return results.)

Sub NoRecords()
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command

conn.ConnectionString = _
"Provider=SQLOLEDB;Data Source=sql70server;" _
   & "User ID=sa;Password=''" ' ;Initial Catalog=pubs
   conn.Open

'Use from the Connection object Execute method
conn.Execute "drop table testtable", , adCmdText + adExecuteNoRecords
conn.Execute "create table testtable (dbkey int primary key, field1 char(10))", , adCmdText + adExecuteNoRecords

'Or from a Command object
Set cmd.ActiveConnection = conn
cmd.CommandText = "insert into testtable values (?, ?)"
cmd.Parameters.Refresh
cmd.Prepared = True

For ii = 1 To 1000
   cmd.Execute , Array(ii, "string" & ii), adCmdText + adExecuteNoRecords
Next
End Sub

Dual Interface Support in ADO

Dual interface support means that ADO supports an IDispatch interface as well as a VTBL interface, so applications written in Microsoft Visual Basic®, Microsoft Visual C++®, and Java can bind directly to the VTBL interface and get fast performance. Scripting languages can use the same objects through IDispatch.

ADO Native Language Bindings

Native language bindings are performance enhancements at the ADO level. The C++ bindings enable developers to bind directly to C data types without overhead for describing metadata or performing VARIANT conversions. Similarly, Java developers can use WFC to bind directly to native Java data types.

ODBC Performance Monitors

The ODBC Driver Manager includes performance monitors for accessing ODBC data, and ODBC connection pooling and other options are configurable from the Microsoft® Windows® Control Panel. These monitors help you tune your application to provide the best performance.