Overview

The ADOCE control provides an ADO-compatible interface to an underlying database engine using a simple subset of Structured Query Language (SQL). SQL commands are sent to the database by means of the recordset.Open method. Using SQL commands with ADO provides a simple object model while fully exposing the features of the underlying database engine.

There are two main types of SQL statements:

Use DDL statements to change the database structure and DML statements to change or retrieve information. For more information on these statements, see Supported SQL Statements.

You can use SQL to create subsets of tables that meet an immediate need without requiring extensive programming. The following code example shows how to use an SQL statement.

dim rs, SQLcommand
set rs = createobject("adoce.recordset")
SQLcommand = "select * from addresses where lastname = 'Smith' order by lastname, firstname"
rs.Open SQLcommand, "", 1, 3, 1

The SQL command consists of the following commands and conditions:

This SQL statement generates a new table using every field from the addresses table. Once the structure of the new recordset has been defined, ADOCE fills the recordset with data. In this example, ADOCE fills the recordset with data about people with the last name of Smith. It also sorts the rows of data by last name and first name, making it easy to find a particular name, such as “James Smith.”