|
| |
ADOCE SQL - Select | Update | Insert | Delete
The SQL command consists of the following commands and conditions:
- select
The select command returns information in a single table
according to the rules you specify. The columns in a table are called fields, and the rows
are called records. In ADO, the table returned by the select statement is called a
recordset. The select statement generates this recordset from existing tables
according to the parameters that follow it.
- from
The * from addresses command notifies the database engine to
return all the fields in the addresses table. The asterisk (*) wildcard character means
all fields. The fields specified here become the columns in the new recordset.
- where
The where lastname = Smith condition restricts the
rows returned to only the ones containing the string Smith in the lastname
field. The rows specified here become the rows in the new recordset. If there are no
Smiths in the addresses table, the recordset is empty.
- order by
The order by lastname, firstname command notifies the database
engine to sort the records before returning them. The engine sorts the records first by
last name, then by first name.
'-- ADOCE Recordset
Dim rs
Select
rs.Open "SELECT * FROM tblName"
Update - Unfortunately there is not an UPDATE SQL statement, so
therefore you must query the database, find the specific record, and perform the update.
rs.Open "SELECT name FROM tblName where name = 'Scott'"
rs("Name") = "ScottL"
rs.Update
Delete
rs.Open "DELETE FROM tblName WHERE name = 'scott'"
Insert
rs.Open "INSERT into tblName (a, b, c) VALUES (101, 102, 103)"
|