Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB6
Expertise: beginner
Nov 6, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Speed up Recordset creation with the CommandType property

If you want to create an ADO Command using VB code, remember to always set the CommandType property to the appropriate adCmdxxxx constant value. If you don't this, will be used the default adCmdUnknow value, and the Data Provider must test the CommandText property to determine if it is a stored procedure, a table name, or a SQL statement before executing the query. This behaviour can cause a significant reduction in performance, because multiple trips to the database server are required.

You should apply this tip to all ADO methods that expect a CommandType argument, such the Open method of the Recordset object:

Dim rs As New ADODB.Recordset
' CN is an open and valid ADO connection object
rs.Open "Authors", cn, adOpenStatic, adLockReadOnly, adCmdTable
Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date