Once you have made your database objects, next you must connect to a database and open
table or run a query on a table. The table or query will get your RecordSet, a set
of records that matches a special set of rules. These records may be updated, or you
can add new records to the table that the record set was queried from, if it was queried
from one table.
To connection to a database you need to give the ADO's Connection object a DSN.
In the case of DomainDLX that would be a DSN string that returns a DSN-Less connection.
(confusing huh?) Well, we do this by calling the Open method.
ADODB.Connection.Open DSNString
To continue from the Starting Point page we would do the following to open a database:
DSNStatement = "DRIVER=Microsoft Access Driver
(*.mdb);DBQ="
DSNStatement = DSNStatement &
Server.MapPath("/USERNAME/database/mydatabase.mdb")
Conn.Open DSNStatement
Now, your database is opened, you just need to open or query a table... This is a
little trickier. A little SQL knowledge will help here. Here we will use SELECT
* (to select any field) FROM Table (from the table Table)
WHERE (((Table.Field)='Value') AND ((Table.Field2)='Value2'))
(where the Field from Table = Value and the Field2 from Table = Value2). This will
explain querying. The only time when you will use WHERE is when you want to query a
select set of record where certain rules apply and in ( ) you place those rules.
Once your table is selected and your rules set and put in a string you need to call the
Open method for the Recordset object.
ADODB.Recordset.Open SQLCommand, ActiveConnectoin, CursorType, LockType, Options
Example:
SQLStatement = "SELECT * FROM Table WHERE "
SQLStatement = SQLStatement & (((Table.Field)='Value) AND
((Table.Field2)='Value2'))
RS.Open SQLStatement, Conn, 3, 3
'These options will open the database for writing while
allowing others to still read it.
By: Matthew Holder