Friday, April 4, 2008

Some ADO Fundamentals


We all are using ADO quite frequently, but we are not sure if we are using it efficietnly too or not. I have given some information below, which may help you out in managing your queries.
While getting a recordset from a connection object.
Set objRS = objConn.Execute(CommandText, [RecordsAffected],[Your Options])
You can speed up your records fetching process by mentioning the options in the recordset object. Following are the options which are available:

adCmdText If you have given the Command Text as a SQL string.
adCmdTable It is a sign that query would return the column names of the table.
adCmdTableDirectfor a table name, whose columns are all returned.
adCmdStoredProc for a stored procedure name.
adCmdFile for a saved recordset.
adCmdUnknown for an unknown command type.
adCmdUnspecified to indicate the command type is unspecified. ADO will work out the command type itself, but this will lead to poorer performance, so you should always explicitly set the command type.

You can also add the following ExecuteOptionEnum modifiers to Options:

adAsyncExecute, for asynchronous execution.
adAsyncFetch, for asynchronous fetching.
adAsyncFetchNonBlocking, for asynchronous fetching that does not block.
adExecuteNoRecords, for a non-row returning command.

Vikas Bhandari

No comments: