Export (0) Print
Expand All

Executing Queries

SQL Server 2000

After an ADO application connects with a data source, it can execute SQL statements on the data source. The general sequence of events in executing an SQL statement is:

  1. Construct the statement.

  2. Execute the statement.

  3. Retrieve any result sets.

After an application retrieves all of the rows in all of the result sets returned by the SQL statement, it can execute another query using the same connection. If an application does not need to retrieve all of the rows in a particular result set, it can cancel the remainder of the result set by calling the Close method to close the Connection object. This closes any active Recordset objects associated with the connection.

If an ADO application must execute the same SQL statement multiple times with different data, you can use the Parameters collection, which consists of Parameter objects that provide parameter information and data to the Command object.

In addition to executing SQL statements, an application can:

  • Execute stored procedures.

  • Execute user-defined functions.

  • Perform batch updates.

  • Generate multiple recordsets.
© 2014 Microsoft