
4.REFERENCING THE DATABASE USER CUSTOMIZE B-75074EN/04
- 438 -
Procedure for reading data
The basic procedure for reading data from the database is described
below.
1 Declare object variables.
Dim tWS As Workspace
Dim tCon As Connection
Dim tRdSt As Recordset
Dim tSQL As String
2 Create an ODBCDirect work space.
Set tWS = CreateWorkspace("", "admin", "", dbUseODBC)
Use the CreateWorkspace method for creation.
By specifying the definition constant dbUseODBC in the
argument Type, an ODBCDirect work space can be created.
When a work space is created with the CreateWorkspace method,
the method returns the Workspace object. By using the Set
statement, store the object in the object variable tWS.
3 As the cursor driver, specify the ODBC cursor library.
tWS.DefaultCursorDriver = dbUseODBCCursor
As a method target object, specify the created Workspace object
tWS.
4 Make a connection to the database.
Set tCon = tWS.OpenConnection(
"iCELL", dbDriverComplete, True,
"ODBC;DSN=iCELL;DATABASE=iCELL.mdb")
To make a connection, use the OpenConnection method.
Specify a data source name in the argument Name, and specify a
real data source name in the argument Connect. For a data source
name and real data source name of the
i CELL, refer to Chapter 3,
"DATABASE SPECIFICATIONS". A read-only connection is
made by specifying True in the argument ReadOnly.
When a connection is made to the database, the method returns the
Connection object. By using the Set statement, store the object in
the object variable tCon.
5 As a character string, create an SQL statement.
tSQL = (SQL statement as a character string)
By using a command such as the SELECT command, create an
SQL statement for acquiring data.