Executing Commands
ADO can work with data, or execute commands, in several ways:
Data can be queried or gathered based on a specific list of qualifications (selection commands).
Data can be manipulated with an action query that usually changes data in some common way throughout your data source (update commands).
Data can be restructured with statements that alter the way the data resides in a particular data source (restructuring commands).
These three types of data gathering and manipulation can be done through either SQL statements or stored procedures. The Connection object allows the execution of both SQL statements and stored procedures directly, through the use of an Execute method. The Execute method can also be used to open an entire table from your data source.
The following sections describe in detail execution of commands.
The Execute Method
There are two different syntaxes for the Connection object’s Execute method. The first is for commands that return information in the form of a Recordset object (see Chapter 5 ), and the second is for commands that do not return anything.
The correct syntax for a call to the Execute method that returns a Recordset object is:
Setrecordset = connection.Execute (CommandText, RecordsAffected, Options)
The correct syntax for a method call that does not return any records is:
connection.ExecuteCommandText, RecordsAffected, Options
Table 4-3 describes each of the components found in these syntaxes.
Table 4-3. The Components of the Execute Method ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access