home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
DATABASE
/
STOCK
/
CSETPP
/
README
< prev
next >
Wrap
Text File
|
1995-06-11
|
8KB
|
186 lines
NAME:
Data Access C++ Stock Sample
FEATURES/CONCEPTS:
This sample illustrates how to use the Data Access Builder Class Library and the code generated by the
Data Access Builder Tool to access DB2/2 database table in a C++ program. It shows how to connect to a
database, manipulate data, make transactions, and disconnect from a database. It also shows how users
can build their own customized classes derived from the Data Access Builder Classes.
TASK:
A simple C++ program that updates stock inventory and received order information that
are kept in two DB2/2 database tables and generates a price list from it.
DESCRIPTION:
This sample program generates a price list from the initial data. It then adds more rows to the
inventory and receivedorder tables, calculates the new values and updates the tables. It then
generates an updated price list.
PROJECT LOCATION:
To locate the CSETPP folder: open the SAMPLE folder, then the DATABASE folder, then the STOCK folder.
SOURCE FILE LOCATION:
X:\ibmcpp\samples\database\stock\csetpp
where 'X:' is the drive you installed the samples and document component
of VisualAge C++.
HOW TO RUN THE SAMPLE PROJECT
You must have started the DB2/2 database manager and logged on before you can run the
sample.
From the WorkFrame environment&colon.
- Double-click on the project's icon to open the project view of the sample. If you have
not already done so, install the database -- double-click on the SETUPDB.CMD to install the
database for the first time, otherwise double-click on RESETDB.cmd to re-initialize the database.
Click on the RUN button of the project's toolbar.
From the command line&colon.
- from the X:\ibmcpp\samples\database\stock\csetpp directory, if you are installing the
database for the first time, type:
SETUPDB.CMD
otherwise, type:
RESETDB.CMD
where 'X:' is the drive you installed the samples and document component of VisualAge C++.
- then type the name of the executable file&colon.
CLIENT
HOW TO BUILD THE SAMPLE PROJECT YOURSELF:
NOTE: You must have started the DB2/2 database manager and logged on before you can build the
sample.
FROM WITHIN THE WORKFRAME ENVIRONMENT:
1) Double-click on the project's icon to open the project view of the sample. You will
see the icons of the files associated with the sample. Double-click on the SETUPDB.cmd icon
if you are installing the database of this sample for the first time, otherwise double-click on the
RESETDB.cmd icon.
2) Start the Data Access Builder clicking Mouse Button 2 on brchone.dax. Select Database on the pop-up menu.
brchone.dax is a prebuilt file which contains the mappings between the database tables and the classes.
3) Select :hp2.Create Classes:ehp2. for brchone.dax, a prebuilt file which contains the mappings between
the database tables and the classes.
Click Mouse Button 2 on each of the class icons (blue balls) in turn, selecting GENERATE -> PARTS
for each from the pop-up menu. Close the Data Access Builder session.
4) From the PROJECT pulldown, select BUILD - REBUILD ALL.
To run the sample project, click on the RUN button of the Project toolbar.
FROM THE COMMAND LINE:
1) Change to the X:\ibmcpp\samples\database\stock\csetpp directory -- where 'X:' is
the drive you installed the samples and document component of VisualAge C++.
If you are installing the database of this sample for the first time, type:
SETUPDB
otherwise, type:
RESETDB
2) Start the Data Access Builder by typing:
ICSDATA BRCHONE.DAX
brchone.dax is a prebuilt file* which contains the mapping between the database tables and the classes.
3) Click Mouse Button 2 on each of the class icons (blue balls) in turn, select GENERATE -> PARTS
for each from the pop-up menu. Close the Data Access Builder session.
4) To build the executable**, type:
BUILD
5) To run the application, type:
CLIENT
* If you want to create the mappings yourself, here are the steps:
a. invoke Data Access Builder without a .DAX file.
b. Select Data Access and click on Create Classes.
c. Select BRCHONE database and click on Connect. Two tables are
now shown in the table list box.
d. Click on Select all and then Create classes. The table class
mappings are now shown.
e. Click on the inventory table icon and select Create class.
f. Double click on the Inventory1 class icon. The class notebook
is shown.
g. On the Names page, change the class name Inventory2 to
PriceList and change the file name Invent1 to prclist.
h. The mapping is done. You can save this mapping by clicking on
Save under Data access.
** There is an alternative way to build the sample program. When
Data Access Builder is invoked from the command line, the make
file for the generated files is created also. You can build the
parts individually by invoking the nmake for it.
nmake -f prclistv.mak
nmake -f receivev.mak
nmake -f inventov.mak
Invoke the nmake on the supplied makefile, client.mak to build
the sample program.
nmake -f client.mak
SOFTWARE/HARDWARE PREREQUISITES:
- IBM VisualAge C++3.0, including the Visual Builder and the Data Access Builder
- OS/2 2.1 or Warp
- DB2/2 1.2
- Minimum : IBM or compatible 386
Recommended : IBM or compatible 486 and up
FILE NAME(S) DESCRIPTION
============ ===========
SETUPDB.CMD This file creates the BrchOne database and populates
inventory and receivedorder tables.
RESETDB.CMD This file re-initializes the two tables back to the
initial setting (intended for use after running the
sample application).
BUILD.CMD This file builds the sample application.
STORE.HPP This header declares a class called Store that uses
the Data Access Builder Class Library and the code
that is generated by the Data Access Builder Tool.
This Store class takes care of connect, disconnect,
transact, and all the data manipulation of database
tables for this sample.
STORE.CPP This source file is the implementation of the Store Class.
CLIENT.CPP The file is the client application that uses the BRCHONE.DAX
This is the saved session from the generations of the
BrchOne classes using the Data Access Builder Tool. It
contains the mapping between the two database tables and
the generated classes. User can use the mapping in this
file to regenerate the database classes.
README This file.
CLIENT.EXE The application.
INVENTOV.BND Bind files produced by SQLPREP when CLIENT.EXE was built.
PRCLISTV.BND They are used to bind the CLIENT.EXE application to the
RECEIVEV.BND database built with SETUPDB.CMD.