Preparation for Samples

Data Access Samples Directory Structure
All files used for the Data Access Builder samples are located in the followingdirectories, where x: is the directory in which VisualAge for C++ is installed:

x:\samples\DATABASE\minisamp\db2cli 
.exe, .icc, .dax files for DB2 CLI mini-samples
                          ..\db2esql
.exe, .icc, .dax files for DB2 ESQL mini-samples
                          ..\odbc
.exe, .icc, .dax files for dBase ODBC mini-samples
                          ..\source
common .cpp file for mini-samples
x:\samples\DATABASE\visual\db2cli 
.exe, .icc, .dax files for DB2 CLI visual sample
                        ..\db2esql
.exe, .icc, .dax files for DB2 ESQL visual sample
                        ..\odbc
.exe, .icc, .dax files for dBase ODBC visual sample
                        ..\source
common .vbf file for visual samples
x:\samples\DATABASE\storproc
files for DB2 stored procedure for DB2 mini-sample
x:\samples\DATABASE\odbc-db
dBase files for sample database CPPASAMP40 (working copy)
x:\samples\DATABASE\odbc-db\backup
backup dBase files for sample database CPPASAMP40

Sample Databases
To work with the Data Access Builder samples, you need to have access to one of the following sample databases:

If you have used the samples, and if the CPPASAMP40 database has been modified as a result, you can restore a copy of the original by copying the files in the x:\samples\database\odbc-db\backup directory to the x:\samples\database\odbc-db directory (where x:\ is the directory where VisualAge C++ is installed).

Using ODBC
The sample database, CPPASAMP40, uses the dBase 5 ODBC driver that is shipped and installed with Data Access Builder. You are not required to perform any steps to use this dBase database with the samples.

Using DB2
If you use DB2 with VisualAge C++, then you have to first ensure that the SAMPLE database has been created on the server that you access. If it has not, then you must create the SAMPLE database yourself, by following these steps. If it has been created, skip to step 4.

  1. Log on:
  2. On the server command line, type the following, where x: is the drive for the database:
    db2sampl x:
  3. On the client, where you have installed VisualAge C++ using the DB2 Client Configuration Assistant, configure the database alias SAMPLE to point to the server. You may need to contact your database administrator to complete this step.
  4. On the server, bind the sample stored procedure file, COLSTATS.DLL, by doing the following:
    1. Copy the x:\samples\database\storproc\colstats.dll file to the y:\sqllib\function directory, where x:\ is the directory where VisualAge C++ is installed and y:\ is the directory where DB2 is installed.
    2. From the x:\samples\database\storproc directory, run the rebind command. If the connect fails when running the rebind command, then edit the rebind.cmd file and replace USERID and PASSWORD with a user ID and password that has access to the database; then, run rebind again.
  5. Start the DB2 Manager by running the following command on the server:db2start
db2start

Sample Database Contents
The sample databases (DB2 SAMPLE and dBase CPPASAMP40) contain several tables used by the Data Access Samples.

DB2 SAMPLE has a table called DEPARTMENT and dBase CPPASAMPA40 has a corresponding table called DEPT, which are used by the following samples:

The DEPARTMENT/DEPT tables have the following columns:

Column SQL Type
deptno CHAR
deptname VARCHAR
mgrno CHAR
admrdept CHAR
location CHAR

The tables also contain a table called EMPLOYEE (DB2) or EMPL (dBase), which is used by the following samples:

The EMPLOYEE/EMPL table has the following columns:

Column SQL Type
empno CHAR
firstname VARCHAR
midinit CHAR
lastname VARCHAR
workdept CHAR
phoneno CHAR
hiredate DATE
job CHAR
birthdate DATE
sex CHAR
edlevel SMALLINT
salary DECIMAL
bonus DECIMAL
comm DECIMAL

The tabljoin sample uses a table join created with columns from DEPARTMENT/DEPT and EMPLOYEE/EMPL. The resulting join, called Query, has the following columns:

Column SQL Type From Table
deptname varchar DEPARTMENT/DEPT
firstname varchar EMPLOYEE/EMPL
lastname varchar EMPLOYEE/EMPL
midinit varchar EMPLOYEE/EMPL

The DB2 sample database contains another table, called EMP_PHOTO, which is used in the following samples:

EMP_PHOTO has the following columns:

Column SQL Type
empno CHAR
photo_format VARCHAR
picture LONG VARBINARY (BLOB)

The DB2 sample database also has a stored procedure defined on it. It is called COLSTATS.



Data Access Builder Workflow


Data Access Class Library and Generated Class Reference
Data Access Builder Samples