Вы находитесь на странице: 1из 318

Borland/!

Builderv



BDE, InterBase Express, ADO Express (dbGo) dbExpress
-
(, )


SQL SQL ANSI-92

dbExpress


MyBase

Quick Report Decision Cube
,

32.973.2
681.3.06(075)

-68
..
-68

Borland C++ Builder 6.


.: , 2003 320 .

ISBN 5-93772-094-6
,
Borland C++ Bulder 6
,
, - .
Paradox Interbase SQL
.
. , . , ^
. :
BDE ,
. BDE, SQL.
Interbase SQL,
SQL-92. dbExpress, MyBase
Briefcase. , ,
Quick Report Decision Cube.
.
32.973.2

.
.
.
, , , . ,
, , .

ISBN 5-93772-094-6

.., 2003
, 2003
77.99.6.953..438.2.9. 04.02.1999


1.
C++ Builder 6

10

12
12
14

SQL Explorer

20
21
24

Database Desktop

26
26

28

2.

29

..

30




Items

(Fields)




TDataSource

34
35
36
37
40
47
50
60
66
67
70
72

TField
, TField
.
(Calculated Fields)

75
78
82
85

"

Borland C++ Builder 6.

(Lookup Fields)


8i
9
9J
10(

102

3.
()

103

101


TDatabase
TDatabase
BDE

TDatabase

10
106
10S
111
113

TSession 114
TSession
115
Paradox dBASE.... 117

119

121


,
( TDBChart)
TDBCtrlGrid
( TDBGrid)
Columns. TColumn


OnTitleClick

OnDrawColumnCell

128
128
130
131
135
136
136
144
149
149

TQuery
SQL



159
159
160
160
760
161

153

.'

(DML)
(Select)
Select
From
Where
Group By.
Having
Order By
(Delete)
(Insert)
(Update)
(Union)

SQL
(DDL)
(Create Table)
(Alter Table)
(Drop Table)
(Create Index)
(Drop Index)

161
161
161
762
765
768
768
769
169
169
170
170
171
171
173
173
175
175
175
176

SQL TQuery.
(SQL Builder)
RequestLive

176
179
180
182

TUpdateSQL

182

TBatchMove

189

192

193

4. -

195

Interbase
Interbase (IBConsole)
ISQL

196
197
202

Interbase
, Interbase
SQL

204
204
205
206

Borland C++ Builder 6.

(Domains)


(Generators), (Triggers)
(Stored Procedures)
(Views)
(Exceptions)

209
211
216
277
226
229
230



dbExpress
IBExpress
dbGo (ADO)
dbExpress
TSQLTable
TSQLQuery, TSQLStoredProc TSQLDataSet
TSQLCIientDataSet
TSQLMonitor

232
233
234
237
240
245
246
260
263
270

273

5.

275

QuickReport


TQuickRep

Quick Report

275
276
279
282
291
296

Decision Cube

297

302

304

, ,
, . , , Oracle,
,
(Paradox, dBASE .).
.
.
. .
,
, .
, , .
Borland C++ Builder.
,
BDE, C++ Builder
. 6.
, Borland C++ Builder 6 . dbExpress
SQL (DB2, Oracle, Interbase
.). (
) dbExpress , - (CLX).
C++ Builder . BDE dbExpress,
IB Express ADO Express (
dbGo). IB Express Interbase, ,
. dbGo,
Microsoft OLE DB, , ., MS Access MS SQL
Server ( , Microsoft).
, BDE ( , ), ,

( ), .
(Paradox, dBASE).
- Interbase dbExpress.

Borland C++ Builder 6.

.
, , .
., , )
, ,
.
( ). Borlan
C++ Builder ,
, ,
. SQL Explorer,
Database Desktop.
.
BDE.
TDataSet <
. , ,
, , .
, .
TDataSource TField,
, .
Master/Detail , , .
BDE . , TDatabase TSession. , Data Controls. TDBGrid (),
. SQL, (Paradox, dBASE, Foxpro ).

TDataSet TQuery.
.
TUpdateSQL TBatchMove, .
, . Interbase.
IBConsole Interactive SQL. ,
IBConsole Interbase,
, Interbase. Interactive SQL,
SQL .
Interbase. , Interbase, SQL Interbase, Interbase,
. ,
- :
dbExpress, IBExpress dbGo (ADO) Interbase, dbExpress,
,


MyBase. TSQLMonitor.
, . Quick Report Decision Cube. ,
.
, . !



C++Builder





SQL Explorer Database Desktop

, ,
C++,
, . , ,

C/C++.
. , ,
- .
C/C++
C++ Builder Borland. Borland (Borland
Database Engine, , , BDE). BDE DLL,

. BDE (Paradox, dBASE, ) SQL (Oracle, DB2, Informix, Interbase, MS SQL
Server .). ODBC (Open Database Connectivity),
, Access, Excel, FoxPro, Btrieve
.
,
.
Borland C++ Builder . C++ Builder
, , , -

1. C++ Builder 6

. , , . C++ Builder .
BDE :
G dbExpress, SQL.
Q ADOExpress ,
ADO. ,
Microsoft,
OLE DB.
G IBExpress ,
Interbase Interbase, BDE.
, ,
. ,
, , Windows . (
, , ..) Quick
Report (QReport) Decision Cube.
()
C++ Builder 6 ( MIDAS),
( 2, Business-To-Business, Web Services), .
( )
,
, ,
. ,
,
,
, , ,
,
.
, Borland C++ Builder 6.
, . , , SQL Explorer Database
Desktop. ,
, .
, , .

I2

Borland C++ Builder 6.

:

Borland C++ Builder 6 !
, .
, ;
, .
(
,
, !
, , . , /
,
, , ,
, , .
, ,
, . ,
, ,
.
, . ,
.
(Database Application) , ,
. ,
() ,
, . :
,
.
,
(, ,
),
. , ()
(Data Model).
. ,
.


, . .
.
, , . ,
.
, .
, , -

1. C++ Builder
, .
(, ..), ,
, ,
, .
, OLE DB,
ADO, .
. ( !), , . .
Q .
( )
. ()
.
(, ) . ,
,
, . ,
,
. dBASE, FoxPro, Paradox.
- , , . , , -
. (..
, ) .
, , . ,
. - .
Microsoft Access.
Q - , , ,
. - . -
,
. , (, ).

- ,
.
( ), (- ),

14

Borland C++ Builder6.

.
SQL-, SQL-;
. SQL-;
, , Interbase, Oracle, DB2, Sybase, Informix, MS SQL Serv<
, .
Q . (multi-tiered)
- . nepcnei
.
.
, cej
. ,
.
,
.
.
, , ,
, . !
,
,
. ]
( , )
.
.
, . {
, , , i
. , , ?
, .
, ,
.
. , ,
, - ().
.
.
- , -
. -


, - ,
, . , , , , , . ,
,

1. C++ Builder 6

15

,
.
,
. , . ,
,
. , .
, , , .
,
.
Q . ,
, .
, , , . ,
,
. ,
.
.
, ,
. : .
.
, ,
,
1-2 ,
. , ,
.
. , , .
, ,
. . , -.
Q , .
, (, ), .
, (),
. ,
(), .
Q , .

, ,

10

Borland C++ Builder 6.

. ,
, - .
, , .
, , ,
. .
1. , .
, .
,
, .
.
, . , ,
.
?
?
?
?
,
, .
? , ,
, ,
, ? .
?
?
?
. ,
, ( ) ,
, ..
, , ?
, , , ?

, ?
? (,
.
: , ..)
() , ,
?

1. C++ Builder

17

- , . , .
2. () .
() .
, .
, , () , , ,
, .. ,
. ,
, , , , Web-
. ,
() .
. , ,
.
, ,
.
.

(Normalization).
5. () . , ,
. ,
. , .
t. , .
,
. (
) (Primary Key). . ,
, , ,
. ,
, , , . ,
. , ,
. , ,
. , ,
, , .
, ,
, ,
. .
() .

10

Borland C++ Builder 6.

. ,
.
,
, (Foreign Keys,
, (
), :
!
( ) !
. .
5. , !
, .
() ,
. , ,
, , .
, , ,
.. , , ,
: , - !
NULL (..
),
(.. *
, ).
6. }!
, . .
, .
, . ,
. . ,
, .
, ,
, . ,
, Big Technologies, 5. ,
5, Big Technologies. , - 5,
,
5. , , (Referential Integrity). ,
,
, .
.
( Microsoft Access CASE-)
SQL-.
,
, .

1. C++ Builder 6


--. ( ) .
. - --. -- , .
.

.
-- .
, , , --. -- .
, .
, ,
-. , . ,
-,
-.

. .
7. .
, ,
,
. , ,
, . ,
, ,
. ,
.
. ,
.
, . , . ,
, . ,
,
, . , , ,
.
, .
.
, ,

Borland C++ Builder .

. ,
, . ,
, .

. , ,
, (, 100 000)
.
, 100 , .
8. . ,
,
,
. , .
:
; . (, , Microsoft Access, Interbase).
,
.
, .
(
, ). - , ,
.
, . : , ,
.
, C++
Builder 6, SQL Explorer (Database Explorer) Database Desktop. ,
. ,
, , ,
, .

SQL Explorer
SQL Explorer ,
. , , ,
. ,
SQL-. , SQL Explorer'a (Alias) , (Dictionary)
(Attribute Set). .

1. C++ Builder 6

21

SQL Explorer C++ Builder 6 Enterprise.


Professional,
Database Explorer, .
SQL Explorer.
SQL Explorer : C++ Builder (IDE
C++ Builder, IDE) .
Explore Database, dbexplor.exe,
BIN , C++ Builder (
$()). ,
. , Windows,
Window . , , . 1.1.
Qbtecl

X .- : ':

I All Database Aliase


Detebese s ) DicSoi

Definition 1

) Databases

+. Ho DefauHDD
+ *o IBLocal
t; TJ myAccees
P. Access
:*j Ti Visual FoxPro
"S " & Visual FoxPro
-f. TJ dBASE
jj TS Excel

Type
STANDARD
DEFAULT DRIVER PARADOX
ENABLE BCD
FALSE
PATH
Deprogram Files\Common Files\Boriwid Shoied\Data

. 1.1. SQL Explorer


. 1.1, SQL Explorer'a
(Left Pane) (Right Pane).
. : Databases ( ) Dictionary ().
.


Databases
(Aliases). (Alias) , , BDE (Borland Database Engine) . SQL Explorer,
BDE Administrator Database Desktop, .
, BDE,
, .
SQL Explorer ,
. , C++
Builder BCDEMOS,
DefaultDD, IBLocal (. . 1.1). Paradox,

22

Borland C++ Builder 6.

Interbase ( ,
, Interbase). , !
, <
ODBC ( . 1.1 ).

, ODBC
. , DSN- (Data Sourc
Name). ODBC (32
(ODBC Administrator), ,
(Control Panel)
Object SQL Explorer.
. New Object Hi
,
(. . 1.2). ( ): STANDARD, MSACCESS, SYBASE, ORACLE,
MSSQL, INFORMIX, DB2, INTRBASE. , , , . STANDARD Paradox
( db), dBASE FoxPro ( /^),
( txt). , . , Apply
Object.

. 1.2. New Database Alias


. ,
STANDARD! INTRBASE1.
Rename .
SQL Explorer, Definition, .
. ,
STANDARD, : ( ),
DEFA ULTDRIVER ( PARADOX, DBASE, FOXPRO
ASCIIDRV), ENABLE BCD ( - BCD) PATH ( ).
, .
, SQL-, .
, .
, . , ,
SQL-. ,
. ,
( ). ,

1. C++ Builder 6

23

Informix DATABASE NAME, Interbase SERVER


NAME, STANDARD PATH. , , ,
.
, , (, ).
. ,
. ,
, , ,
.
!

Databases jpidronaryj
;-; Q) Databases
EV BCDEMOS
:
& Tables
- animals dbt
Ms
: : Ot NAME
: ilH SIZE
i ; t DB WEIGHT
: AREA

_*j

_J

Prnls

Nome
: Type
Siie
NAME
CHARACTER 10
SEE
NUMERIC

EWEIGHT NUMERIC
2
fflAREA
CHARACTER 20
BMP
BINARY
10

H,y
10

10

; BMP

Indices
.fiUfl VelidiV Checks
1 Referential Constraints
i ,*i gg Securrty Specs
| b'fil FamiV Members
5Fld,,,l-:.db.,

. _. i. j i

Jj

. 1.3. animals ,
BCDEMOS
SQL Explorer
. , , . . ,
STANDARD ,
MSACCESS .
SQL-. , Interbase .
: Domains (), Views (), Procedures (),
Functions (), Generators (), Exceptions () Blob Filters
( Blob).



. Interbase SYSDBA
masterkey.
. , SQL ,
. ,
Interbase IBConsole, InterBase Guardian.

24

Borland C++ Builder 6.

, , .
Apply Object.
- Ctrl + A.B .

, ,
: , , , ^
, .. . 1.3
Summary animals (
BCDEMOS. ,
..
SQL Explorer
. ,
Data.
, . HI
, SQL Explorer. ITpi
,
, .

! Detnbane Aliases
Detebages j Dicjionaty
Databases
6CDEWOS
Tables
!* H animals dbf
*. bk)lTte,db
1

QD countrydb
cusioiy.dQ
OS customer db
!__ employee. db

ahcce Category-' Sheik'

jj ^

<l

-IJ . ""

^i

{Category |Cornnion_Nani( jSpeeiasName., .


~*j
HShark
Swell Shark
Cephatoscyilium ventrtosur {
J Shark
Nurse Shark
Ginglyrnostoma cirratum ^ i

tj <} '

-M-:-

_>J

. 1.4.
Enter SQL. ,
.
SQL. Execute Query
. . 1.4 .
.
, SQL- .


(Dictionary) , .
. (Attribute Set) ,
() . . 1.5
CustNo. , , , .

1. C++ Builder 6

25

.*/ SampteOea DfOreroy


, Oirionay)
i - Dictioneiy
r-: El Database!
: - BCDEMOS
-flB DBDEMOS
;
-v dQASE
S Attribute Sets
Company
:+ H Continent
Referencing Fielt
BCDEMOS.O.:
-BCOEMOS or
EOHOEMuviujd

. 1.5. CustNo
.
,
,
( ). ,
, ,
. , ,
.
, New Object.
, , ,
( Close Object). Create a new
Dictionary (. . 1.6). (
), ( Databases) ,
. , .

:". ( IBLocal

. 1.6. Create a new Dictionary


Databases Attribute Sets.
.
Attribute Sets
New.
EXTFIELD1.
.

() . . Import to Dictionary

26

Borland C++ Builder 6.

( Databases).
Databases Dictionary.

SQL Explorer.

DatabaseDesktop
Database Desktop , SQL Explorer.
Paradox,
dBASE SQL, , , , , , . Database Desktop .
Database Desktop Tools,
dbd32.exe. /Common Files/Borland Shared/
Database Desktop/. , Database Desktop. .


, New \
Table File. Create Table
(, ).
Paradox dBASE, ODBC SQL-. : FOXPRO, MSACCESS,
SYBASE, ORACLE, INFORMIX, MSSQL, DB2 INTRBASE.
, Create Table. . 1.7 Interbase.

:teble>_StoreNo

s-tor,.

. 1.7. Interbase
Create Table ,
, (Field Name)
().
(Size) (Dec).
(Size). , . .
, .

1. C++ Builder

27

,
. SQL-.
Database Desktop .
, StoreNo - ( Size),
. , ,
.
. , .
, ,
, (Borrow Struct).
, Create
Table Borrow Struct. Select Borrow Table,
Windows . (Alias), , .
(Open). Create
Table ,
. ,
dBASE Interbase. , ,
.

*.db *.dbf,
. Alias Select Borrow Table
None. ,
.

Select Borrow Table


. , :
/ (Primary index), (Validity check),
(Lookup table), (Secondary index),
(Referential integrity).

. 1.8.

28

Borland C++ Builder 6.

Create Table )
. , SQL !
. 1.8.
. , ,
. Paradox .
(Referential integrity), (Secondary indexes),
. ,
SQL. SQL Explorer.

, , -|
,
SQL Explorer Database Desktop . ,
.
C++ Builder ,
SQL Explorer, a Database Desktop
, , .
, .
*.db * dbf ,
(Alias). .
, Database Desktop . ,
(QBE Query By Example), , , , . Database Desktop.
, , ,
Database Desktop, SQL Explorer.

. ,
, , . ,
, .
, , .
, C++ Builder 6. SQL
Explorer Database Desktop ,
. , , ,
. ,
.

BDE

BDE
liable
, ,
TDataSource

TField

Master/Detail

, .
,
, .
, :
- ,
,
.
,
BDE. BDE
Borland. BDE API,
, , .
BDE
. . (FoxPro, dBASE, Paradox,
) Microsoft Access
(Native) . , BDE .
. , SQL
Links, (Interbase, DB2, Oracle,
Informix, MS SQL Server Sybase). ODBC, BDE ( ,
ODBC).

30

Borland C++ Builder 6.

BDE.
, , C++ Builder . , : BDE
C++ Builder . ,
(Data Controls) VCL BDE. .
, BDE . BDE
,
. , ,
BDE, . , ,
. , . ,
, , SQL-.
1C. ,
,
BDE.
, BDE . BDE, , . ,
. , , . . BDE
, , .
BDE , Borland
.
,
BDE. . , , BDE . -,
, ,
. BDE . .
BDE,
, .

.
-


, - , - . , . Database
Desktop Paradox 7.
(. . 2.1):
1. Field Name CategoryNo, Type Autoincrement (+), Key * .

2.

31

2. Field Name Category, Type Alpha (A), Size 25.


3. Field Name Description, Type Alpha (A), Size 50.

. 2.1. Category
, . 2.1,
, Big
Computer. , .. .
Autoincrement (
+). ,
Paradox.
CategoryNo ,
. Autoincrement
.


CategoryNo. , .
Post ( ) SQL
Explorer.
CategoryNo , Key. (*).
, Key ,
. Paradox
, <Primary>. , , (Secondary Indexes).
(Alpha). Category 25 , Description 50
. Category , Required Field.
,
(Validity Checks).
. - , -

32

Borland C++ Builder 6.

, D:\Data. , Save As, ]


Category. category.db ;
category.px ( primary key) category. v>
( Validity Checks). . ,
category.xgO category.ygO ( ), categi
ry.xgl category.ygl .. MEMO category, mb .^
1
, Paradox , ,
, , .

, ,
.
Table properties Table Language Modify. Hi
,
Paradox ,
Paradox Cyrr 866. . Database Desktop, ,
. SQI
Explorer .
, , . , ,
. ,
(Paradox, dBASE, FoxPro) , . , SQL Explorer
STANDARD. DEFAULT DRIVER PARADOX (
), , Category (, D:\Datd).
- (, MyData) ( Apply
Object).
Category .
SQL Explorer. MyData ( ) Category.
SQL Explorer Data. , ,
. 2.2. , ( ). Insert
record ( +), Delete record ( -),
Post edit ( ).
1;
2
'

5 .

7
8
9.
10
11 '
t?

! , ,
Intel AMD
Intel. Amd VIA
DIMM. DIMM DDR RlMM
Radeon GeForce
- -
Fujitsu, Samsung Western Digrtel
, , ..
, , CD-ROM

, ,

. 2.2. Category

2.

33

,
. C++ Builder ()
SQL Explorer. MyData,
Category. : TDBGrid ()
() viTDataSource ( ). , .
, . Active true. ,
. ,
. 2.3. ,
TDBGrid .
, . , TDBGrid ?
TDBGrid .
DataSource. ( ),
DataSourcel TDataSource, .
DataSourcel, , DataSet
Table]. DatabaseName Tablel
MyData, TableName Category.db. .
- TDBGrid
Active true.

1
i
2

3 Intel AMD

. 2.3.

C++ Builder
(, TDBGrid) .
DataSource,
DataSourcel, DataSet,
Table?. , Tablel,
DatabaseName TableName. ,

.
, (Data Controls), TDBGrid
TDBEdit, .
2 . 319

34

Borland C++ Builder 6.

, TDataSet (
). ,
Database TableName. TDataSet TQue,
() TStoredProc ( ).
, ,
, , Heni
, , , :
, . .
TDataSource,
(, TQuery TStoredProc)
(TDBGrid, TDBEdit .). , <
, ,
.

TDataSet TQuery, TDataSource, TDatabase, TFiek
,
, BDE.


C++ Builder , !
BDE. Borland ^
BDE, Data Access <
BDE .
TDataSet, !
, . TDataSet , .
. TDataSet , , , , , (. . ).
, , . . ,
. TDataSet
.
TDataSet,
,
. .
, - , : (Delete Table), (Rename Table),
(Update Table Definition), SQL Explorer (Explore).
(,
) , . , , . ,
TDataSet
(, TQuery, TStoredProc), , ,
. TDataSet,
(, TQuery, TStoredProc).

2. BDE

35


.
( ). Active
- TDataSet true,
. false () . , , . , ,
().
, DatabaseName TableName ( ), Active false.
Active
, . ,
Category , , , .
Active true , , . ,
,
. , .
Active :
false,
.
Active Open Close.
Active TDataSet :

property bool Active =


(read=GetActive, write=SetActive, default=0};
Active .
.

if(Tablel->Active)
else

ShowMessage("Ha6op !");
ShowMessage(" !");

Active / . , ,
. ( TButton
Standard) (Name) DeactButton (Caption) Deactivate.
OnClick :
Tablel->Active=!Table1->Active;
if(Tablel->Active) DeactButton->Caption="Deactivate";
else
DeactButton->Caption="Activate";
: Active . , .
. Status,
OnClick , . , -

36

Borland C++ Builder 6.

Deactivate, ,
Status (. . 2.4).
/ <
Open Close. .

void
void

fastcall Open(void);
fastcall Close(void);


Active. Open Active true, Close
false. , OnClick DeactButton
:

if(Tablel->Active)
{
Tablel->Close() ;
DeactButton ->tion="Activate";
}
else
{
Tablel->0pen();
DeactBut ton->Caption="Deactivate";
}
, Active
, Open Close .

1 ;9
2-


' :

3'

' -1!""
*"!"!^.
; -" .I^fio^:aeHM*'0'TXjjt#?{'' " j, DIMM. DIMM DDR RIN-f^
' ":/
^'

. 2.4. Active



DatabaseName TableName. Exclusive, Paradox dBASE .
.
DatabaseName
. , .

( dBASE, FoxPro, Paradox).
DatabaseName , . ,

2.

37

MyData, Category
, DatabaseName
D:\Data ( , Category).
; , , TableName,
. DatabaseName ,
: dBASE, FoxPro, Paradox. ,
.
, ,
, ( ). , .

DatabaseName TableName . :
property AnsiString DatabaseName =
{read=FDatabaseName, w r i t e = S e t D a t a b a s e N a m e } ;
property AnsiString TableName =
{read=FTableName, write=SetTableName};
,
DatabaseName TableName. ,
.

Tablel->Active = false;
Tablel->DatabaseName = "MyData";
Tablel->TableName = "Category";
Tablel->Active = true;
Tablel->Active = false;
Tablel->DatabaseName = "D:\Data";
Tablel->TableName = "Category";
Tablel->Active = true;
,
. ,
, .

Items
,
. ,
, Big
Computer. , Category.
Database Desktop.
Paradox 7 :
Q ItemNo. () Autoincrement.
Key, .
Q Item. () Alpha, (Size) 50.
. Required Field, .

38

Borland C++ Builder 6.

Q Category. () Long Integer. Required Field


Category, . .
. , Category,
1
Category. :
, i
. , Long Integer ;
Autoincrement.
Q Description. () Alpha, (Size) 100. ,
.
Q Index. () Alpha, (Size) 5. 5
,
. Index ,
, Items
.
( ..) ,
. , <
, .. Inde
. ,
, ,
. ( )
, Index , Required Fields
.
Price. () Money. Price .
.
Items . 2.5.

. 2.5. Items .
Items Category. Table properties ( )
Referential Integrity Define.
, .

2.

39

Items (. . 2.6), (..


, ).
: Child fields, Parent s key. Category
.
Child fields. Category
. Database Desktop Parent s key
Category. , Cascade Update rule,
Category Items. , Strict
referential integrity. Paradox
.

, .. ,
(
).

. 2.6. Referential Integrity


Database Desktop
.
. , , Category , . , (Referential Integrity),
R I CategoryRI.

Items Category,
Items Category. Table properties
Dependent tables ( ). ,
Items.db , Category.
, Items , , .
Table properties Secondary Indexes.
, Category.
.

40

Borland C++ Builder 6.

, \
Item, . >
Define Define Secondary Index (Fields) Item. ,
(Indexedfields) .
. - ItemNDX(cM. . 2.5).

, ,
, , Category
Item. , - ,
.
Data Items Database
Desktop. Items , SQL Explorer Data. , , Description, . ( ItemNo,
) .
Category , CategoryNo
Category.
Items, ,
Data.


. (, , ) .
TDBNavigator .
TDBNavigator, , Form] TTable, TDataSource TDBGrid
, .
Items Active true.
TDBNavigator. , ,
( Data Controls), DataSource.
TDBNavigator TDataSource.
.
, TDBNavigator,
SQL Explorer, .
( ).
, , (. . 2.7):
(First), (Prior), (Next), (Last).
,
. 2.7
Items .
- , .
VisibleButtons.

2. BDE

41

. . false,
.
, , .

1;SamsungML-4SQO
'
3 Epson EFt-590QL
:
4 CanonLBP-810
5 Brother HL-1 240 Mono Laser
6 Epson AcuLoserCIQOO
7 Epson AcuLsssrC200D
B:HPLaserJet1000w
10:HP Laser JetlZZG
11 HP LaseiJet 3200
12:HP Laser JelZZQG
13 -Epson Stylus Color CJOSX
HJEpsor. Stylus Color DUX
15 lEpson Stylus Color C60

GDI, 600dp,, a:',


, ;';
!, 16(5;-;
:4 ! . GD '/
^ (?)/''
"4. 60'J dp
-. BCD dp
;A4.

. 720 dpl.

-A1. . 2883x72^

' -

. 2.7. TDBNavigator
,

:

void _fastcall Fi rst(void)


void _fastcall Prior(void)
void _fastca!1 Next(void);
fastcall Last(void) ;
void
int fastcall MoveBy(int Distance);
property bool Bof = (read = FBof, nodefault};
property bool Eof = (read=FEof, nodefault};

//

//


. MoveBy Distance . Distance , .
(). , MoveBy(1) Next{),
MoveBy(-l) Prior(). MoveBy() ,
. Distance.
, ,
, , .
Bof (Begin of file) Eof (End of file) , . Bof
true :
U ;
Q First ( ,
);

42

Borland C++ Builder 6.

Prior, ;
Q SetRange .
/ false.
Eof, true :
G ;
G Last;
Next, ;
1_1 SetRange .
/ Eof . , , .
(, AfterScroll
TTable) / Eof, , ,
.
, ,
(Bof = = true + Prior) (Eof ' = = true +
Next)
.

Bof Eof TTable, . ,
VCL TPanel.
TPanel , Caption.
,
, Bevellnner bvRaised, BevelOuter bvLowered.
, , ( TButton).
Name ( ): BFirst, BPrior, BNext BLast,
Caption First, Prior, Next Last .
Tag 1 (BFirst), 2 (BPrior), 3 (BNext) 4 (BLast)
, ,
. .
TEdit, TButton.
BMoveBy ( Name) (Caption) MoveBy.
TEdit Text. ( ):
EPlan EReally. . , ,
TEdit
(TLabel). (Caption): Bof Eof ( ).
TEdit Text : EBofu EEof. , ,
.
( TDBGrid(DBGridl)),
TDataSource (DataSourcel) TTable (Tablet). , . Table 1 Items, Active
false. , . 2.8.

2.

* : i Fffrfj Pnpfj Ne^j: 1!I ' ; i

43

~% McveByj j

. 2.8. ,
Bof Eof
, ,
. BFirst,
Events OnClick. C++ Builder
BFirstClick. OnClick (
). :
void

fastcall T F o r m l : : B F i r s t C l i c k ( T O b j e c t *Sender)
TButton * Temp;
Temp=dynamic_cast<TButton *>(Sender);
if(Temp)
switch(Temp->Tag)
case 1:
Tablel->First(); break;
case 2 :
Tablel->Prior(); break;
case 3:
Tablel->Next(); break;
case 4:
Tablel->Last(); break;
BFirst->Enabled=!Tablel->Bof;
BPrior->Enabled=!Tablel->Bof;
BNext->Enabled=!Tablel->Eof;
Blast->Enabled=!Tablel->Eof;

Temp TButton.

TButton Sender. ,

44

Borland C++ Builder 6.

(, ).
, :
. , !
Tag . ,
Tag 1 4. ,
, . !
/ 0/ .
/, BFirst BPrior , !
Eof BNext BLast. Bofvam Eof '
false, .
BMoveBy
EPlan EReally.
, EPlan BMoveBy, ,
,
EReally. , OnClick
BMoveBy :

void
{

fastcall TForml::BMoveByClick(TObject *Sender)


EReally->Text=IntToStr
(Tablel->MoveBy(StrToIntDef(EPlan->Text,0)))

}
StrToIntDef
EPlan->Text AnsiString . StrToIntDef ,
. , MoveBy,
AnsiString EReally.
EPlan
Enter. , OnKeyPress EPlan :

void
{

fastcall TForml::EPlanKeyPress(TObject Sender, char &Key)


if(Key == VK_RETURN) BMoveByClick(NULL);

}
, ,
(. . , ASCII)
, . , Enter
(VK_RETURN ,
Enter), BMoveBy NULL.
/ / , ,
/ Eof TTable.
, A/terScroll TTable. ,
, , ( ,
). AfterScroll :

2.
void

45

fastcall TForml::TablelAfterScroll(TDataSet *DataSet)


if(DataSet->Bof)
else
if(DataSet->Eof)
else

EBof->Text="true";
EBof->Text="false";
EEof->Text="true";
EEof->Text="false";

AfterScroll DataSet. .So/ ./ ,


/ EEof.
, ,
: BFirst BPrior (
). OnCreate
Forml:
void

fastcall TForml::FormCreate(TObject *5ender)


Tablel->0pen();
BFirst->Enabled=false;
BPrior->Enabled=false;

( NavMethods) .
.
2.1 2.2.
2.1. NavMethods
#ifndef UnitlH
#defme UnitlH
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <DBCtrls.hpp>
#include <OBGrids.hpp>
#include <DBTables.hpp>
#include <ExtCtrls.hpp>
#include <Grids.hpp>
class TForml : public TForm
published:
// IDE-managed Cdmponents
TTable *Tablel;
TDataSource *DataSourcel;
TDBGrid *DBGridl;
TButton *BFirst;
TButton *BPrior;

46

Borland C++ Builder 6.

TButton *BNext;
TButton *BLast;
TPanel *Panell;
TPanel *Panel2;
TButton *BMoveBy;
TEdit *EPlan;
TEdit *EReally;
TPanel *Panel3;
TEdit *EBof;
TLabel *Labell;
TLabel *Label2;
TEdit *EEof;
void _ fastcall FormCreate(TObject *Sender) ;
void _ fastcall BFi rstClick(TObject *Sender) ;
void _ fastcall BMoveByClick(TObject *Sender);
void _ fastcall EPlanKeyPress(TObject *Sender, char &Key)
void _ fastcall TablelAf terScroll (TDataSet *DataSet);
private: // User declarations
public:
// User declarations
_ fastcall TForml(TComponent* Owner);
extern PACKAGE TForml *Forml;
//-- ........ #endif
2.2. NavMethods

#include <vcl.h>
#pragma hdrstop
#include "Unitl.h"

#pragma package(smart_init)
#pragma resource "*.dfm"
TForml *Forml;
_fastcall TForml : :TForml(TComponent* Owner)
: TForm(Owner)

void _ fastcall TForml : :FormCreate(TObject *Sender)


{
Tablel->0pen() ;
BFi rst->Enabled=false;
BPrior->Enabled=false;
void _ fastcall TForml : :BFirstClick(TObject *Sender)

2.

47

TButton * Temp;
Temp=dynamic_cast<TButton *>(Sender);
if(Temp)
switch(Temp->Tag)
/
case 1:
Tablel->First(); break;
case 2:
Tablel->Prior(); break;
case 3:
Tablel->Next(); break;
case 4:
Tablel->Last(); break;
BFirst->Enabled=!Tablel->Bof ;
BP r i or ->Enabled=! Table l->Bof;
BNex t->Enabled=! Table! ->Eof;
Bias t->Enabled=! Table!- >Eof ;

void _ fastcall TForml: :BMoveByClick(TObject *Sender)


t

EReally->Text=IntToStr
(Tablel->MoveBy(StrToIntDef (EPlan->Text ,0)

void _ fastcall TForml : :EPlanKeyPress(TObject *Sender, char &Key)


{
if (Key == VK_RETURN) BMoveByClick(NULL) ;
void _ fastcall TForml: :TablelAf terScroll (TDataSet *DataSet)
if(DataSet->Bof)

else

if (DataSet->Eof)

else

EBof->Text="true";
EBof->Text="false"
EEof->Text="true";
EEof->Text="false"

(Fields)
Fields.
TFields , TField.
TField . TField
, . TField
, Fields.

48

Borland C++ Builder 6.

, TFields ,
, .
TFields:

property int Count = {read=GetCount, nodefault};


_property TDataSet* DataSet = {read=FDataSet};
property TField* Fieldsfint Index] =
{read=GetField, write=SetField};
. DataSe
, Fields.
- . Count :
TField, .
. Fields :
[].

TFields . ,
(, TCIientDataSet),
.
AggFields.
TFields , (TField). :
TField* operator [] (int Index) { return Fields[Index] ; }
TField*
fastcall FieldByNumber(int FieldNo);
TField*
fastcall FieldByName(const AnsiString FieldName);
[] . (
!).
, . ,
Items 0 ItemNo, 1 Item, Price 5. Count 6.
: ItemNo 0,
Item \ ..

. (Fields Editor), .
, ,
. , ,
Description , ,
. ,
,
Add fields. , Description ( , Ctrl) . ,
Description.

2.

49

, .
, /7 FieldByNumber. ,
. FieldByNumber , , [] .
, , . , ( TLabel),
TListView, . . Items MyData. , , ( Description ). TListView.
,
: Index, Fieldsflndex] FieldByNumber [Index].
, ViewStyle
vsReport. OnCreate :
void _ fastcall TForml: :FormCreate(TObject *Sender)
{
Tablel->0pen();

Labell->Caption=
" Items " +
IntToStr(Tablel->Fields->Count)
+ " : " ;

TListltem *Temp;
for(int i=0;i<Tablel->Fields->Count;i++)
Temp=ListViewl->Items->Add() ;
Temp->Caption=i ;
Temp- > Subl terns ->Add (Table l->Fi eld s->Fi elds [i] ->FieldName) ;
Temp- >SubI terns ->Add (Table l->Fi elds ->FieldByNumber (i+1) ->FieldName) ;

.
[] FieldByNumber (. . 2.9).

Count TF/e/ds ,
. , ,
Items, Tab/e7->F/e/ds->Count 5,
. F/eldCount
(, TDataSet).
, ,
FieldByName.
TField, . ,

50

Borland C++ Builder 6.

.
FieldByName,

Tablel->FieldByName("Item") '
Tablel->FieldByName("Description")

// Item
// Description

Hems cc

::
Item temNo
' Category
* Jridex .. _
. Price
: Qeacriptipn

2
4
5

l(

rr 4 0

?. '' '
Iten
: Category
.1 Description
i Index
: Price

. 2.9. FieldByNumber ,
,

,
,
. BDE . . ,
, , .

:

void
fastcall ApplyRange(void);
void
fastcall CancelRange(void);
void
fastcall EditRangeEnd(void);
void
fastcall EditRangeStart(void);
void
fastcall SetRange(const System::TVarRec * StartValues,
const int StartValues_Size, const System::TVarRec * EndValues,
const int EndValues_Size);
void
fastcall SetRangeEnd(void);
void
fastcall SetRangeStart(void);
, , TDataSet.
,
() , .
Q ,
. IndexFieldNames,
IndexName. IndexFieldNames AnsiString, , .
IndexName, , ,
. , ,
, .
Q , .

2.

51

SetRangeStart SetRangeEnd. EditRangeStart EditRangeEnd.


Q , ApplyRange. CancelRange .
, Items
Category. , Paradox
. Items,
Category 3 5.

Table1 ->DatabaseName="MyData";
Tablel->TableName="Items.db";
Tablel->IndexFieldNames="Category";
Tablel->0pen();
Tablel->SetRangeStart();
Tablel->FieldByName("Category")->AsInteger=3;

Tablel->SetRangeEnd();
Table!->FieldByName("Category")->AsInteger=5;
Tablel->ApplyRange();
SetRangeStart SetRangeEnd ApplyRange SetRange, . SetRange-
( ) . :

Tablel->DatabaseName="MyData";
Tablel->TableName="Items.db";
Tablel->IndexFieldNames="Category";
Tablel->0pen() ;
Tablel->SetRange(OPENARRAY(TVarRec,(3)), OPENARRAY(TVarRec,(5)));

OPENARRAY ,
, .
, OPENARRAY(TVarRec,(3))
SetRange, OPENARRAY(TVarRec,(5)) - .
/ Open/Array Object Pascal,
.
, C++ , VCL,
Object Pascal, .
OPENARRAY ARRAYOFCONST
Borland C++ Builder.
. , ,
TDBGrid, TDataSource,
Items , . ,
. (TPanel).
(TButton).
: BPriorCat, BNextCat, BPriorRec, BNextRec, : Prior Category, Next
Category, Prior Record, Next Record. (TEdii),

52

Borland C++ Builder 6.

(TLabel) . BApply, BCancel Apply Rang:


Cancel Range . ECat Text
Category.
. 2.10.

tefrtNe|ft*m --. : '-I .,'... jCetago-ylDescrioion


*]
1 MustekScariExpress1200UBPk
2 CCD. . .4. 36 . f \.;"
2 Mustek ScenExpress 1200 USB F
3 Mustek ScnnExpress A3 EP
2 OS. . A3, 36 , ' i.
2 CCD. . 4 True Col> : !:i
A HP ScanJet 2200C
5 HP ScanJet 4
2 <;;:|
6 HP ScanJet 44COC
2 CCD, . 4, True Col' . ;,
7 HPScartJeH47QC
2 CCO, , < True Col.; ^il
8 HP ScanJet 540QC
2 : CCO, . At True Coir .: ;.

iLJ

. 2.10. ApplyRangeDemo

. , Forml, , :
long int C a t ;

Cat
. OnCreate
:

void _ fastcall TForml: :FormCreate(TObject *Sender)


{
Tablel->IndexFieldNames="Category" ;
Tablel->0pen() ;
Cat=l;
SetFilterCat(l) ;
BPriorCat->Enabled=false;
BPriorRec->Enabled=false;
FormCreate
, (Category),
, Items. Cat
, ( SetFilterCai).
,
BPriorCat ( ) BPriorRec (
). .
SetFilterCat
. (Unitl.h, ), private (
public, ,
):

void _ fastcall SetFilterCat (long int Cat);

2.

53

Unit 1. :
void

fastcall TForml::SetFilterCat(long int Cat)


if(Cat == 0) return;

Tablel->SetRangeStart();
Tablel->FieldByName("Category")->AsInteger=Cat;
Tablel->SetRangeEnd();
Tablel->FieldByName("Category")->AsInteger=Cat;
Tablel->ApplyRange();
ECat->Text=IntToStr(Cat);
BApply->Enabled=false;
BCancel->Enabled=true;

}
SetFilterCat , .
Cat 0, .
. SetFilterCat ECat
Apply Range Cancel Range. ,
TDBGrid ,
. Aslnteger TField Integer. Aslnteger TField
, .
.

KeyExclusive boo/;
.
,
. ,
, 4 5.
Tablel->SetRangeStart();
Tablel->FieldByName("Category")->AsInteger=3;
Tablel->KeyExclusive=false;
Tablel->SetRangeEnd();
Tablel->FieldByName("Category")->AsInteger=5;
Tablel->ApplyRange();
, , OnClick. BPriorCat OnClick
Tablel->First(), BNextCat Tablel->Last(),
BPriorRec BNextRec Tablel->Prior() Tablel->Next().
, (. . / Eof true) ,
.
OnClick (BPriorCat, BNextCat, BPriorRec BNextRec)

Borland C++ Builder 6.

54

Enabled
,
, , .
OnClick ,
. , ^
, ECat.
. . ,
.
,
,
. 2.3 2.4.
2.3. ApplyRangeDemo
//

#ifndef UnitlH
#define UnitlH
//
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <DBGrids.hpp>
#include <DBTables.hpp>
^include <Gn'ds.hpp>
#include <ExtCtrls.hpp>
//
class TForml : public TForm
{
published:
// IDE-managed Components
TDBGrid *DBGridl;
TTable Tablel;
TDataSource *DataSourcel;
TPanel *Panell;

TButton *BPriorCat;
TButton *BPriorRec;
TButton *BNextCat;
TButton *BNextRec;
TPanel *Panel2;
TEdit *ECat;
TLabel *Labell;
TButton *BApply;

TButton *BCan.cel;
void fastcall FormCreate(TObject Sender);
void fastcall BPriorCatClick(TObject *Sender);
void fastcall BNextCatClick(TObject *Sender);
void
fastcall BNextRecClick(TObject *Sender);
void
fastcall BPriorRecClick(TObject *Sender) ;
void fastcall BCancelClick(TObject *Sender);
void fastcall BApplyClick(TObject *Sender);

2.

private: // User declarations


void _ fastcall SetFiUerCat(long int Cat);
public:
// User declarations
_fastcall TForml(TComponent* Owner);
extern PACKAGE TForml *Forml;

//
#endif

2.4. ApplyRangeDemo

#include <vcl.h>
#pragma hdrstop
#include "Unitl.h"
#pragma package(smart_ini t)
#pragma resource "*.dfm"
TForml *Forml;
long int Cat;
_fastcall TForml: :TForml(TComponent* Owner)
: TForm(Owner)

void _ fastcall TForml: :FormCreate(TObject *Sender)


{
Tablel->IndexFieldNames="Category" ;
Tablel->0pen() ;
Cat=l;
SetFilterCat(l);
BPriorCat->Enabled=f alse;
BPriorRec->Enabled=false;
void _ fastcall TForml: :BPriorCatClick(TObject *Sender)
{
Tablel->First() ;
if (Cat != 0)
{
if(Cat > 1) Cat--;
SetFilterCat(Cat);
ECat->Text=IntToStr(Cat) ;
Tablel->Last() ;
}
if(Cat < 2) BPriorCat->Enabled=false;
if (BNextCat->Enabled == false) BNextCat->Enabled=true;
if (BNextRec->Enabled == false) BNextRec->Enabled=true;

55

56

Borland C++ Builder 6.

void _ fastcall TForml : : BNextCatClick(TObject *Sender)


{
Tablel->Last() ;
if(Cat != 0)
{
if (Cat 12) Cat++;
SetFilterCat(Cat) ;
ECat->Text=IntToStr(Cat) ;
}
if(Cat == 12) BNextCat->Enabled=false;
if (BPriorCat->Enabled == false) BPriorCat->Enabled=true;
if (BPriorRec->Enabled == false) BPriorRec->Enabled=true;
void _ fastcall TForml : :BNextRecClick(TObject 'Sender)
{
Tablel->Next();
if (Tablel->Eof)
{
if ((Cat == 12) | | (Cat == 0))
{
BNextRec->Enabled=false;
BNextCat->Enabled=false;
}
if(Cat != 0)
{
if(Cat 12) Cat++;
SetFilterCat(Cat) ;
ECat->Tex.t = IntToStr(Cat) ;
if (BPn'orRec->Enabled == false) BPriorRec->Enabled=true;
if((Cat == 2) && (BPriorCat->Enabled == false))
BPriorCat->Enabled=true;
if((Cat == 12) && (BNextCat->Enabled == true))
BNextCat->Enabled=false;
void _ fastcall TForml : :BPriorRecClick(TObject *Sender)
{
Tablel->Prior() ;
if(Tablel->Bof)

if(Cat < 2) BPriorRec->Enabled=false;


else
{
if (Cat > 1) Cat--;
SetFilterCat(Cat) ;
ECat->Text=IntToStr(Cat) ;
Tablel->Last() ;

2.

57

if(BNextRec->Enabled == false) BNextRec->Enabled=true;


if((Cat == 11) && (BNextCat->Enabled == false))
BNextCat->Enabled=true;
if((Cat == 1) && (BPriorCat->Enabled == true^)
BPriorCat->Enabled=false;

void

fastcall TForml::5etFilterCat(long int Cat)


if(Cat == 0) return;

Tablel->SetRangeStart();
Tablel->FieldByName("Category")->AsInteger=Cat;
Tablel->SetRangeEnd();
Tablel->FieldByName("Category")->AsInteger=Cat;
Tablel->ApplyRange();
ECat->Text=IntToStr(Cat);
BApply->Enabled=false;
BCancel->Enabled=true;
void

fastcall TForml::BCancelClick(TObject *5ender)

Cat=0;
Tablel->CancelRange();
BApply->Enabled=true;
BCancel->Enabled=false;
ECat->Text="All";
BPriorCat->Caption="Fi rst Record";
BNextCat->Caption="Last Record";
void

fastcall TForml::BApplyClick(TObject Sender)

Cat=StrToIntDef(ECat->Text,0);
if ((Cat < 1) || (Cat > 12)) Cat=l;
SetFilterCat(Cat);
BPriorCat->Caption="Prior Category";
BNextCat->Caption="Next Category";

Filter, Filtered
FilterOptions. TBDEDataSet, TDataSet . Filter
Filtered , , , .
.
.
Filter , , . -

58

Borland C++ Builder 6.

:
=.
, Category=3, Filter, ,
, 3. , , ,
. , , .
, : [ ].
:
(<>), (>), (<), ..
, Filtered
true. ,
. , Filtered
false.

FilterOptions, . FilterOptions FilterOption: foCaselnsensitive KfoNoPartialCompa, .
. FilterOptions foCaselnsensitive,
.
FilterOptions foNoPartialCompare . foNoPartialCompare , . , ,
Item- 'S*' , Item
S. FilterOption ,
true .
Filter Filtered . , , , (TDBGricf), TDataSource, ,
Items. , .
2.11, . (
TEdit) ECriteria, (TCheckBox) CBCaselnsensitive CBNoPartialCompare . (TButton) : Apply BCancel.
^rtteria Stfjpg: & ^
'**
ttemNo

"

r NO *
CwcsiRterj

|
3 Epson EPL-5900L
6 Epson AcuUasef C1000
7 EpsonAcuLaserCZDOO
3 Epson Stylus ColorCSDSX
4 Epson Stylus ColorCMQUX
5 Epson Stylus Color C60
6 Epson Stylus Color C70
7 Epson Stylus ColorCfiO
Epson Stylus Photo B1Q

jcafcij.!^ |''s *]
A^ IJJ4,
A4;>."'l
A4.-.',;:;^
A4 . ,
:
A-f ,.|

A1 v.:^
:
A4 "-

A4..;.|
'A4 "'-&

JLJJ

. 2.11. Item
^
Filter Filtered

2.

59

OnCreate OnClose :
void
{

fastcall TForml::FormCreate(TObject

*5ender)

Tablel->0pen();

void
{

fastcall TForml::FormClose(TObject *Sender,


TCloseAction &Action)
Tablel->Close();

}
, , :
Tablel , .
OnClick BApply BCancei.
void
{

fastcall TForml::BApplyClick(TObject *Sender)

Tablel->Filter=ECriteria->Text;
if(CBCaseInsensitive->Checked)
Table1->FiIterOptions foCaselnsensitive;
else Tablel->FilterOptions foCaselnsensitive;
if(CBNoPartialCompare->Checked)
Table1->FiIterOptions foNoPartialCompare;
else Tablel->FilterOptions foNoPartialCompare;
Tablel->Filtered=true;

}
void
{

fastcall TForml::BCancelClick(TObject *Sender)


Tablel->Filtered=false;

}
BCancei Filtered false', .
BApply
, ECriteria, ,
ECriteria, Filter, ,
CBCasefnsensitive CBNoPartialCompare,
FilterOption. , Filtered
true.
! ,
.
. . 2.11 Items, Item.
, Case Insensitive , No Partial Compare
. . . 2.11 ,
Item sam Sam (
) (,
).

60

Borland C++ Builder 6.


OnFilterRecord . TDataSet
:

typedef void _ fastcall ( _ closure *TFilterRecordEvent)


(TDataSet* DataSet, bool &Accept) ;
( ) DataSet
, Filtered tru>
, ,
Accept - false. OnFilterRecon

pax . Edit
Edit2.

void _ fastcall TForml: :TablelFilterRecord(TDataSet *DataSet,


bool &Accept)
{
Accept=
(DataSet->FieldValues["Price"J >= StrToIntDef (Edi tl->Text ,0))
&&
(DataSet->FieldValues["Price"] <= StrToIntDef (Edit2->Text, 1000)) ;

,
. SetKey ( EditKey
GotoKey . :

void _ fastcall SetKey(void) ;


void _ fastcall Edi tKey (void) ;
bool __ fastcall GotoKey (void) ;
void _ fastcall GotoNearest(void) ;
, , .
IndexFieldNames ( , ), IndexName ( ). ,
: Field '_ ' is not indexed and cannot be modified (
'_ ' ). SetKey. , dsSetKey.
-
. , ,
IndexFieldNames IndexName.
GotoKey .
() ,
true . , GotoKey ^/^.
EditKey , SetKey, -

2.

61

, .
, , , ,
. SetKey
, , , ,
. GotoKey ,
EditKey , ,
. GotoKey , , , .
, Item Items.

Tablel->IndexName="ItemNDX";
Tablel->SetKey();
Tablel->FieldByName("Item")->AsString=ESample->Text;
Tablel->GotoKey();
Tablel->IndexName="";
,
. , Items Item
ItemNDX. SetKey,
, Item ,
ESample. GotoKey
,
. .
, IndexName ItemNDX,
Item ,
ItemNDX ( ). , ,
, .
(. . ). , ,
, IndexName.
, ,
GotoKey GotoNearest. ,
.
. GotoNearest , , .
, GotoKey GotoNearest, . FindKey FindNearest. :

bool
void

fastcall FindKey(const System::TVarRec * KeyValues,


const int KeyValues_Size);
fastcall FindNearest(const System::TVarRec * KeyValues,
const int KeyValues_Size);

( ), .
. , -

62

Borland C++ Builder 6.

OPENARRAY ARRAYOFCONST.
FindKey FindNearest SetKey
, , . , ,
, :

Tablel->IndexName="ItemNDX";
Tablel->FindKey(OPENARRAY(TVarRec,(ESample->Text)));
Tablel->IndexName="";

Locate. TBDEDataSet ( ,
TDataSet) :

virtual bool fastcall Locate(const AnsiString KeyFields,


const System::Variant &KeyValues, Db::TLocateOptions Options);
, ?
TBDEDataSet (TTable, TQuery, TStoredProc).
,
Locate AnsiString,
. .
Variant.
, .
Variant VarArrayOf.
TLocateOptiom. loCaselnsensitive (
) loPartialKey ( ).
Options .
, Locate.

void fastcall TForml::BLocateClick(TObject *Sender)


{
TLocateOptions SearchOptions;
SearchOptions.ClearQ;

if(CBCaselnsensitive->Checked) SearchOptions loCaselnsensitive;


if(CBPartialKey->Checked) SearchOptions loPartialKey:
Tablel->Locate(EField->Text, ESample->Text, SearchOptions);

}
CBCaselnsensitive CBPartialKey . EField, ESample.
Lookup , ,
.
TBDEDataSet :
virtual System::Variant
fastcall Lookup(const AnsiString KeyFields,
const System::Variant SKeyValues, const AnsiString ResultFields);
Lookup , , .

2.

63

.
Locate (. ). AnsiString. ,
. , - Items,
, :

EField->Text=Tablel->Lookup("Item","HP LaserJet 1200","Index");


, FindFirst, FindPrior, FindNext FindLast.
, , ,
, , , . , Find...
. FindFirst, FindPrior, FindNext FindLast
TDataSet :
bool
bool
bool
bool

fastcall
fastcall
fastcall
fastcall

FindFirst(void);
FindPrior(void);
FindNext(void);
FindLast(void);

true
false .
OnFilterRecord , .
Filtered false.
. , OnFilterRecord,
.
Find... OnFilterRecord, . , TDBGrid, TTable TDataSource, .
Items
MyData.
(: EField ESample), (: Field Sample) (:
BFindFirst, BFindPrior, BFindNext, FindLast; , : Find First, Find
Prior, Find Next, Find Last; Tag, : 1,2,3, 4).
, . 2.12.
BFindFirst OnClick OnClick .
:
TButton* Temp=dynamic_cast<TButton *>(Sender);
if(Temp)

swi tch(Temp->Tag)

case 1: Tablel->FindF1rst(); break;


case 2: Tablel->FindPrior(); break;
case 3: Tablel->FindNext(); break;

64

Borland C++ Builder 6.

case 4: Tablel->FindLast(); break;


};
DBGridl->SetFocus();
]

,
.
Sender TButton *, , ,
Tag, !
( ).
TDBGrid.
OnFilterRecord:

Accept=(DataSet->Fields->
FieldByName(EField->Text)->As5tring.AnsiPos(ESample->Text)

0) ;

,
EField. AsString
AnsiString. AnsiPos AnsiString
, , ESample, !
. , AnsiPos , (
Accept true, Find...
, true. FindPrior FindNext nonet
, .

^5

Hum

tewnNo

r|

jttem

:JFC-PGA

-*.-

.-

*SfjlS

V.FiBdtosr;;::.!
---:--'

""

'

'

63 Socket A GIGA-BYTE GA-7ZXE


63 Socket A GIGA-BYTE GA-7ZX Rev. 5X
6< Socket A ChaJnTBchCT-7AJA2
65 Socket A GIGA-BYTE GA-7ZMMM
66 Socket A ASUS A7V133-C
HJfl Socket 370 FC PGA/PPGA Canvon 6LEBMS
68 Socket 370 FC-PGA/PPGA Canyon SLEBMS-T
69 Socket 370 FC-PGA/PPGA Menli 899

FBiti^fe<l

."-.

"

:|

jCetegor*}

'

>
LJ

7C Socket 370 FC-PGA/PPOA PC ParlnerT205C


71 Socket 37C FC-PGA/PPOA FoslFame 3SLAP
72 Socket 370 FC-PGA/'PPGA PC Partner C203T

, ...

;i

. :-?-<

:,.; .,.;;:.;j;,^

. 2.12. ,
FindFirst, FindPrior, FindNext FindLast
-, , FindFirstDemo, . . 2.12
Item 'FC-PGA'. BFindPrior BFindNext,
, , . BFindFirst BFindLast , , .
FindFirstDemo 2.5 2.6.

,
, .

2.

65

, ,
, , , . .
, , .
2.5. FindFirstDemo

//

------

...............................

- ............................

#ifndef UnitlH
#defme UnitlH
// ------ ......................... - ..... -------- ............. -------#include <Classes . hpp>
#include <Controls . hpp>
#include <5tdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <DBGrids.hpp>
#include <DBTables.hpp>
#include <Grids.hpp>
// ..... - ..... - ............ - ............ ---- ............... ---- ......
class TForml : public TForm
{
_ published:
// IDE-managed Components
TDBGrid *DBGridl;
liable "Tablel;
TDataSource *DataSourcel;
TEdit *EField;
TLabel *Labell;
TEdit *ESample;
TLabel *Label2;
TButton *BFindFirst;
TButton *BFindLast;
TButton *BFindPrior;
TButton *BFindNext;
void _ fastcall BFindFi rstClick(TObject *Sender);
void _ fastcall TablelFilterRecord(TDataSet *DataSet,
bool &Accept) ;
void _ fastcall FormCreate(TObject *Sender) ;
void _ fastcall FormClose(TObject *5ender, TCloseAction &Action);
private: // User declarations
public:
// User declarations
_fastcall TForml(TComponent* Owner);
extern PACKAGE TForml *Forml;
/ / ----- .................. #endif
2.6. FindFirstDemo

#include <vcl.h>
#pragma hdrstop
3 . 319

Borland C++ Builder 6.

66

#include "Unitl.h"

#pragma package(smart_ini t)
#pragma resource "*.dfm"
TForml *Forml;
_fastcall TForml : : TForml (TComponent* Owner)
: TForm(Owner)

void _ fastcall TForml: :BFindFi rstClick(TObject *Sender)


{
TButton* Temp=dynamic_cast<TButton *>(5ender);
if (Temp)
{
swi tch(Temp->Tag)
{
case 1: Tablel->FindFi rst() ; break;
case 2: Tablel->FindPrior() ; break;
case 3: Tablel->FindNext() ; break;
case 4: Tablel->FindLast() ; break;
};
DBGridl->SetFocus() ;

void _ fastcall TForml : :TablelFilterRecord(TDataSet *DataSet,


bool &Accept)
{
Accept=
(DataSet->Fields->FieldByName(EField->Text)->
AsString.AnsiPos(ESample->Text) > 0);
void _ fastcall TForml: :FormCreate(TObject *Sender)
{
Tablel->0pen() ;
void
_fastcall
&Action)
{

TForml: : FormClose(TObject

*Sender,

TCloseAction

Tablel->Close();


. , . IndexName IndexFieldNames.

2. BDE

67

, , ,
, , , . , , , . (
), .
, . TQuery.


, ,- , . , , ,
. DeleteTable
.
, TDataSet .
, TDataSet, :

void
fastcall Append(void);
void
fastcall AppendRecord(const System::TVarRec * Values,
const int Values_5ize);
void
fastcall Delete(void);
void
fastcall Edit(void);
HIDESBASE void fastcall Insert(void);
void
fastcall InsertRecord(const System::TVarRec * Values,
const int Values_Size);
TBDEDataSet :

virtual void
virtual void

fastcall Cancel(void);
fastcall Post(void);

,
, , , .
( Cancel)
( Post). .
Insert , . dslnsert, . ,
, (. .
), Post.
Cancel.
Insert,
Post ( ),
.
Q Paradox, ,
.
Q Paradox ,
.

Borland C++ Builder 6.


G dBASE, FoxPro Access . !
- ,
.
SQL
( ),
.
, Cancel.
InsertRecord ,
Post.
InsertRecord
OPENARRAY ARRAYOFCONST. , InsertRecord,
, .

InsertRecord ,
Autoincrement Required Field (
). ,
. , ,
, ,
, .
Append AppendRecord ,
Insert InsertRecord ,
. Delete, . , . , .
.
Edit (dsEdif). , .

Post. Cancel , ( dsBrowse). Index .
Tablel->Edit();

Tab!el->FieldByName("Index")->AsString=EIndex->Text;
Tablel->Post();
Insert, Append Edit CheckBrowseMode
, .
, , . : Beforelnsert, BeforeEdit, BeforeDelete,
BeforePost, BeforeCancel, Afterlnsert, AfterEdit, AfterDelete, AfterPost, AfterCancel.

, . , Delete BeforeDelete, , , AfterDelete. , ,
.

2.

69

Before
- , . , , , . After
- , . BeforePost. , .
, .
, .
, , ,
Cancel. Abort, ( ), . No, Abort,
, Cancel. ,
, .

void _ fastcall TForml: :TablelBeforePost(TDataSet *DataSet)


{
int resp;
resp=Application->MessageBox("CoxpaHHTb ?",
" ",
MB_YESNOCANCEL+MB_ICONQUESTION);

swi tch (resp)

case IDCANCEL:
{ AbortQ; break; }
case IDNO:
{ DataSet->Cancel() ; AbortQ; break; }

, . , . .
. : Cannot modify a read-only dataset
( ). ,
CanModify.
. true, ,
. ,
CanModijy true, ,
SQL . .
,
,
(
).
. Readonly true;
CanModify //. Readonly
, , ,
CanModify.

70

Borland C++ Builder 6.

TDataSet Modified.
, , .


, ,
.
Bookmark. !
TDataSet :
property
AnsiString
wri te=SetBookmarkStr};

Bookmark

{read=GetBookmarkStr,

,
Bookmark AnsiString. , AnsiString,
Bookmark. , BSaveBookmark
BRestoreBookmark , TDBGrid, TDataSource TTable, Items
MyData.
. ,
, .

BRestoreBookmark. AnsiString (, MyBookmark),
OnClick :

void fastcall TForml::BSaveBookmarkClick(TObject *Sender)


{
MyBookmark=Tablel->Bookmark;
}
void fastcall TForml::BRestoreBookmarkClick(TObject *Sender)
{
Tablel->Bookmak=MyBookmark;
}
GetBoohnark,
GotoBookmark FreeBookmark. TDataSet :

v i r t u a l void * fastcall GetBookmark(void);


void
fastcall GotoBookmark(void * Bookmark);
virtual void fastcall FreeBookmark(void * Bookmark);
TDataSet,
.
, GetBookmark, GotoBookmark FreeBookmark
void*.
TBookmark, db.hpp :

typedef void "TBookmark;

2. BDE

,
GetBookmark.
TBookmark. GotoBookmark.
GetBookmark FreeBookmark,
, GetBookmark.
Bookmark,
, BGetBookmark
BGotoBookmark. , Forml,
:

TBookmark MyTBookmark;
OnClick BGetBookmark BGotoBookmark
:

void
{

}
void
{

fastcalT TForml::BGetBookmarkClick(TObject *Sender)


MyTBookmark=Tablel->GetBookmark();
fastcall TForml: :BGotoBockmarkClick(TObject *Sender)
Tablel->GotoBookmark(MyTBookmark);
Tablel->FreeBookmark(MyTBookmark);
MyTBookmark=NULL;

}
BGotoBookmark
FreeBookmark , MyTBookmark
GetBookmark. MyTBookmark
NULL. , ,
BGetBookmark . OnClose :

if(MyTBookmark) Tablel->FreeBookmark(MyTBookmark);
,
MyTBookmark. NULL, ,
FreeBookmark.
, ,
.
BookmarkValid, TBDEDataSet :

virtual bool

fastcall BookmarkValid(void * Bookmark);

TBDEDataSet, , TQuery. TBookmark,


, , BookmarkValid true.

, , -
. , (unidirectional)

72

Borland C++ Builder 6.


. ,
, IsUniDirectional.

TDataSource
, ,
. , Post ,
,
: Dataset not in edit or insert mode (
). , Post, ,
.
State.
TDataSet :

property TDataSetState State = {read=F5tate, nodefault};


State, , .
TDataSetState:
dslnactive , - .
dsBrowse .
.
dsEdit .
, , .
, , .
, Post (
) Cancel ( ).
dsBrowse.
G dslnsert , , Insert Append.
,
. dsEdit, ( , ) Post Cancel
dsBrowse.
dsSetKey . , ,
SetRange. dsSetKey TClientDataSet.
dsCalcFields
OnCalcFields (. . ( ) ). ()
.
Q dsFilter - State
OnFilter-Record. .
.

2. BDE

73

U dsNewValue, dsOldValue dsCurVahie. , BDE . TField NewValue, OldValue CurValue


.
dsBlockRead , .
, .
Q dslnternalCalc BDE
, ( FieldKind)
fklnternalCalc. Tvm&fklnternalCalc , , irniufkCalculated, .
( TField) .
Q dsOpening. , .
State . TDataSource
State TDataSetState, ,
TDataSource. , TDataSource. ,
, TDataSource.
TDataSource , . , C++ Builder,
TDataSource (conduit) . ,
, TDataSource,
. ,
TDataSource,
,
(Data-aware Controls) -
. , TDataSource
-- ( /
(Master/Detail)).
TDataSource : State,
AutoEdit, DataSet Enabled. State TDataSetState .
State TDataSource ,
Enabled false DataSet, State dslnactive
.
Enabled ,
.
false .
DataSet TDataSet,
TDataSource. ,
, Enabled true, DataSet

74

Borland C++ Builder 6.

TDataSet (, , :
, ).
, ;
TDBGrid , TDBGrid,
(dsEdit). (
- Options TDBGrid) dgAlwaysShowEditor
Enter F2, ;
.
, AutoEdit
TDataSource true. AutoEdit false,
Edit.
.
TDataSource, ,
: IsLinkedTo Edit. Edit
TDataSource , . AutoEdit. true, . (dsBrowse),
Edit . , Edit TDataSource
,
.
IsLinkedTo , TDataSource
TDataSet. .

TDataSource. : OnDataChange, OnStateChange OnUpdateData.
TNotifyEvent, OnDataChange :

typedef void

fastcall ( closure *TDataChangeEvent)


(TObject* Sender, TField* Field);

OnDataChange
, , (, ). ,
Field NULL. To Field , .
.
, , , ,
.
OnUpdateData ,
, BeforePost. .
, , OnStateChange
, , . -

2. BDE

75

, , ,
.
OnStateChange,
ModifyRec,
. IDE C++ Builder TStatusBar.
( Align alBottom). SimplePanel
TStatusBar true SimpleText .
OnStateChange :

void

fastcall TForml::DataSourcelStateChange(TObject *Sender)


AnsiString StatusText;
switch(DataSoureel->State)
case dslnactive: { StatusText="Inactive"; break; }
case dsBrowse: { StatusText="Browse"; break; }
case dsEdit: { StatusText="Edit"; break; }
case dslnsert: { StatusText="Insert"; break; }
case dsSetKey: { StatusText="SetKey"; break; }
case dsCalcFields: { StatusText="CalcFields"; break; }
case dsFilter: { StatusText="Filter"; break; }
case dsNewValue: { StatusText="NewValue"; break; }
case dsOldValue: { StatusText="01dValue"; break; }
case dsCurValue: { StatusText="CurValue"; break; }
case dsBlockRead: { StatusText="BlockRead"; break; }
case dsInternalCalc: { StatusText="InternalCalc"; break; }
case dsOpening: { StatusText="Opening"; break; }
default: 5tatusText="Unknown" ;
StatusBarl->SimpleText="DataSet Status: " + StatusText;

, .
.
.
,
.

TField
TField (,
..). , . TField , , ,
C++ Builder.
, 2.1.

Borland C++ Builder 6.


2.1. TField

TADTField

TObjectField.
ADT (Abstract Data Type).
ADT (), . ADT.

TAggregateFi eld

TField. .
.
, , .

TArrayField

TObjectField.
. .
(, ),
(, ADT).

TAutoIncField

TInteger Field, ,
,
TNumericField. .

TBCDField

TNumericField. - (Binary Coded


Decimal). BCD ,
.

TBinaryField

TField.
.

TBlobField

TField. , BLOB (Binary Large Object).

TBooleanField

TField.
.

TBytesField

TBinaryField.
Byte.

TCurrencyField

TFloatField, TNumericField.
Currency.

TDataSetField

TObjectField.
, ,
(nested) .

TDateField

TDateTimeField.
, .

2.

77

TDateTimeField

TField.
, .

TFloatField

TNumericField.
, .

TFMTBCDField

TNumericField.
- BCD (Binary
Coded Decimal). TFMTBCDField TBCDField . C++ Builder 6.

TGraphicField

TBlobField.
, .

TGuidField

TStringField.
,
(GU1D Globally Unique Identifier).

TIDispatchField

TInterfaceField.
, IDispatch.

TIntegerField

TInterfaceField

TField. ,
, (lUnknown).

TLargelntField

large integer.

TMemoField

TBlobField.
MEMO.

TReferenceField

TObjectField.
, .

TSmalllntField

TIntegerField, , , TNumericField.
small integer.

TSQLTimeStampField

TField.
Date/Time dbExpress. C++ Builder 6.

TStringField

TField.
.

TTimeField

TDateTimeField.
, .

TVarBytesField

TBytesField, ,
, TBinaryField.
.

TNumericField.

TNumericField.

78

Borland C++ Builder 6.

TVariantField

TField.
Variant.

TWideStringField

TStringField.
WideString.

TWordField

TInteger Field,
TNumericField.
Word.

TField .
, , , ,
, ,
. TField
-
. , -
. , , TField,
, TStringField, FixedChar Transliterate,
.
- TField: . , ,
.

, TField
TField . , , .
C++ Builder.
TField . As , .
, .
.

Ansi String Price=Tablel->FieldByName("Price")->AsString;


int IntPrice=Tablel->FieldByName("Price")->AsInteger;
Currency CurPrice=Tablel->FieldByName("Price")->AsCurrency;
.
.
CurValue, OldValue NewValue ( )
, , , .
,
TClientDataSet (cached
updates). , (
Post) . OnUpdateError
OnReconcileError CurValue, OldValue NewValue,

2.

79

.
Value, DisplayText Text. Value / ( ) .
. , TCurrencyField, Value Currency. DisplayText Text AnsiString
, . Text . Text
DisplayText OnGetText ,
.
DataType FieldKind .
DataType . DataType
TFieldType. 2.1 - TField. , TIntegerField
ftlnteger, .. FieldKind
TFieldKind:
fkData , .
jkCalculated . OnCalcFields.

fkLookup . .

JklnternalCalc , ,
/kData. ,
SQL, , BDE , RequestLive
true.
jkAggregate .
. Calculated, Lookup,
LookupCache, LookupDataSet, KeyFields, LookupKeyFields, LookupList LookupResultField.
true Calculated , , . . OnCalcFields . . .
AutoGenerateValue. ,
, . ,
. ( Post)
. AutoGenerateValue.
, ,
. AutoGenerate Value
TAutoRefreshFlag: arNone ( ), arAutoInc
( ), arDefault ( ).
, AutoGenerateValue,

, .

80

Borland C++ Builder 6.


DefaultExpression.
, SQL, -|
. ,
, , 'No Item' '15:45'. *
DefaultExpression, , ;
,
.
TField ,
(). ,
. CustomConstraint, ImportedConstraint
ConstraintErmrMessage HasConstraint. CustomConstraint , , . , CustomConstraint,
, ConstraintErmrMessage.
ImportedConstraint , . , ImportedConstraint
. . ImportedConstraint
, , , , .
, , ImportedConstraint,
,
. ConstraintErrorMessage
, .
HasConstraint .
true, .
, : CustomConstraint, ImportedConstraint
DefaultExpression.
FieldKind - fkData, FieldName
,
.
TField
. Islndex true, ()
. IsNull true, . EditMask TEditMask ( AnsiString)
.
TEditMask
C++ Builder.
TField .
BDE. , ,
Assign Clear. Assign Value .
. , TablelDateO->Assign(TablelDatel) DateO Table 1 Datel . ,
Date. TablelDescription->Assign(Memol
->Lines) Description Tablel, Memo, -

2. BDE
Memol, . Clear ,
Value NULL.
TField , .
OnChange, OnGetText, OnSetText OnValidate. OnChcmge
, .
,
. OnChange OnValidate,
. OnChange , ,
. OnChange , .
OnValidate .
, . OnValidate

. , ( throw).
OnChange .
OnGetText OnSetText :
typedef void

fastcall (

typedef void

fastcall (

closure *TFieldGetTextEvent)(TField* Sender,


AnsiString &Text, bool DisplayText);
closure *TFieldSetTextEvent)(TField* Sender,
const A n s i S t r i n g T e x t ) ;

OnGetText DisplayText
Text TField. ,
, . TDBGrid OnGetText ,
. Sender ,
, Text
AnsiString.
, Text
. , TDBGrid,
OnGetText,
. , OnGetText, Text.
, Text AsString .
OnGetText -,
:

void

fastcall TForml::TablelItemGetText(TField *Sender,


AnsiString &Text, bool DisplayText)

Text=Sender->AsString;

82

Borland C++ Builder .

OnGetText
DisplayText. , , Text
.
- .
OnSetText , Text
. Text,
const, Text .
Text . ^
OnGetText - , OnSetText
.

.
(Dynamic fields),
(Persistent fields).
, .
. . , . ,
, .
.
,
. .
, - ,
. ,
.
FieldDefs
. TFieldDefs
, . FieldDefs
, , ,
. FieldDefs , (Calculated
Fields). (
IndexDefs),
.
(Persistentfields)
, (Fields Editor). , ,
, , . ,
, , .
, , .
TField ( )
.

2.

83

, ( ) . , ,
. ,
. , .
, .
, ,
. ,
,- , .
, , , , .
, , .

tern

temMo

<JJ

Category
jfcKn
328 HUBCompexPS <ndex
329 HUBHPPraCun Price

!CofX>.*l

330 ;
331 HUBEP-ai6DX332 Mel EthE
333 Intel EthE
33-1 Intel Ethe Express Pro/1 Ods Ptl Server Adapt
335 Intel Pro/1DOS Dual Port Server Adapter
336 imel Pro/ COOT
337 HUB Intel Stainda one Managed Switch

:'

. 2.13.

, , . , - TDataSet (, TQuery),
Fields Editor. ,
(. . 2.13).

. , Add fields Add all fields.
, . .
New field
. . : (Data), (Calculated)
(Lookup). (, ClientDataSet),
(Aggregate) IntemalCalc.
. (Data), . ,

84

Borland C++ Builder 6.

, ,
.

.
. , Name Fiel
Name. FieldName ,
, Name . HMCI
,
. , Tablelhem.
. ,
Table!->FieldByName(Item).
,
. ;
( ,
)
. , Item Items
TStringField, Price TCurrencyField. ]
,
, .
Delete.

(Attribute Sets). !
, SQL Explorer.
SQL Explorer,
. Associate attributes. , .
Dictionary SQL Explorer Attribute Sets,
.

, . ,
, , .. , , , . , Unassociate attributes.
,
.
- ,
: Save attributes, Save attributes
as Retrieve attributes. Save attributes ,
, , .
Save attributes as .
Retrieve attributes
.
, . .

2.

, ,
. ,
. ,
( ) TDBEdit,
, , TDBImage. ,

( Tlabel), .
, ,
.
.

(Calculated Fields)
-

(Calculated
Fields), .. , , . , , ,
, .
,
, .
.
.
OnCalcFields ,
. ,
,
, ,
. , , ,
Visible false.
OnCalcFields .->1-.
OnCalcFields
. , , . OnCalcFields :
Q , ;
Q ( dsEdif);
G (, ).
, AutoCalcFields true, OnCalcFields

(TDBGrid) .
,
, AutoCalcFields false,
.
, -

86

Borland C++ Builder .

MyData, , .
. Database Desktop
Paradox 7. , 2.2.
2.2. Employees
(Field Name)

()

(Size)

EmployeeNo ()

Autoincrement (+)

LName ()

Alpha (A)

50

FName ()

Alpha (A)

20

MName ()

Alpha (A)

25

HireDate ( )

Date (D)

FireDate ( )

Date (D)

Description ()

Memo (M)

Photo ()

Graphic (G)

Birthday ( )

Date (D)

(Key)
*

240

LName HireDate Required field . Table properties


Secondary Indexes Define.
LName, FName MName ( )
NameNDX. , ,
Employees. , . , Employees
.
, - . , . (EmployeeNo)
.
. , , ,
Employees. , , .
TDBGrid, TTable TDataSource,
. , , DBGridl DataSourcel, a DataSourcel Tablel. Tablel Employees MyData.
: , , , .
, .
, .. , FireDate (
) . , ,
FireDate NULL. Filter : FireDate=NULL.
,
Employees NameNDX ( IndexName).

2.

87

() ,
: Name ( ), Age (), Standing ().
(, ).
, New field , .
Name, (
_). String
Name Smalllnt Age Standing. Size 50
Name,
. Field type
Calculated. . 2.14 Standing.

. 2.14. Standing
Name, Age Standing
LName, FName, MName, HireDate Birthday. , FireDate,
( ).
Add fie Ids. . Visible
false, .
,
false Visible .
, OnCalcFields :
void _fastcall TForml: :TablelCalcFields(TDataSet *DataSet)
AnsiString FI.SI;
unsigned short yearl, yearO, month, day;
if (!TablelFName->IsNull)
FI=" " + (TablelFName->Value). SubString(0, 1) + "." ;
if((!Table!MName->IsNuU) && ( ! (FI . IsEmpty ()) ))
SI=" " + (TablelMName->Value) . SubString(0, 1) + "." ;
TablelName->Value=TablelLName->Value + FI + SI;
Date() .DecodeDate(&yearl, &month, &day) ;
(TablelBirthday->Value) .DecodeDate(&year0, &month, &day) ;
TablelAge->Value=yearl-year0;
(TablelHireDate->Value) .DecodeDate(&year0, &month, &day) ;
TablelStanding->Value=yearl-year0;

Borland C++ Builder 6.


.
FI SI AnsiString. , i
FName . , IsNull. FNar
, FI , ,
. Substring
AnsiString. ,
, . ,
SI, , , ]:
, . ,
AnsiString IsEmpty.

. 2.15. ,
Value Name
, . : i
, Name .
OnCalcFields (
Age Standing. ( Age)
, . ( Standing)
- .
Date, TDateTime. TDateTime DecodeDat
, .
OnCreate
:

void
fastcall TForml::FormCreate(TObject *Sender)
{
Tablel->0pen();
Tablel->Filtered=true;
}
.
. . 2.15
.


TDataSet TQuery. !
TQuery -.

2. BDE

(Lookup Fields)
(Lookup Fields)
.
.
,
, ,
. , Items Category,
Category. , - . ,
.
,
.
Category Items.
, ,
TDBGrid, TTable TDataSource, . , Tablel
Items MyData. Active Tablel true,
. Category.
(2) .
. ,
Tablel. Add all fields,
. , .
New field. , Field properties,
(Name) ( Category ,
CategoryName), () (Size) ( Category, String 25
).
Field type Lookup, ,
. Lookup definition
: Key Fields Dataset.
Key Fields , ,
. . Key Fields,
, . Category.
Dataset
TDataSet ( : Tablel Table!). ,
.
Tablel, , ( ). 2.
: Lookup Keys Result Field.

90

Borland C++ Builder 6.

: Field ptoperties
: :

Type:.. '.'Sting
;

Field -

Component |ToblelC3tegoryName2 ;.,;

|CrtegoiyJome

^J Site:

|re

'

''. gey field*: ' JGategoi


Lookup Keys: jCainqoiyNo

_Tj Besuft Field; fCotegoi

. 2.16. CategoryName
Lookup Keys ;
(Lookup DataSei). ,
Lookup Keys, , <
Key Fields. >
1
.
, Kt
Fields. CategoryNo.
Lookup definition Result Field.
, Result Fieh
,
. Category. . 2.1
New Field,
CategoryName.
Tablel , .
Category, ,
, Visible //.
CategoryName ,
Item. , :
. : DisplayLabt
CategoryName Category.
.
.
. 2.17.

1J

1 Samsung ML-4500
2 SamsungML-1210
3 Epson EPL-59QQL
A Canon LBP-81Q
5 Brother HL-1Z40 Mono Laser
e.EpsonAcuLossfCIOOO
7 EpsonAcuLaserCZQOO
8 HPLeserJetlCQQw
9 HPLeserJel1200
10 HP LaserJet 1220
11 HP LaserJet 3200

< GDI, 2 , 600 dpi. .


4. GDI, . 600 dpi, . :
4. GDI, 2(1 ) . 600 ^ J
4. GDI, 600 dpi. 8 pprn, i *j
A4. 26. 600x600 dpi, a
\
A4, . 1 6(256) . ,;i.
A4, , 64(51 2) , ":|

:< ! , GDI, 600 dpi, .-*'v:|


8(72) . 1200 dpi, T" 'J
4, 600 dpi 24 : ! i
4. 600 dpi- 24 ,J. '.
JLJ

. 2.17. , Category

2.

91

CategoryName
, . , New field .
FieldKind JkLookup, Field type.
Lookup definition , , KeyFields,
LookupDataSet, LookupKeyFields LookupResultField. ,
, ,
, .
,
, . LookupCache.
true,
.
, .
, .
,
,
, .


, ,- /
(Master/Detail). :
, , , , . ,
(Master) , (Detail). -,
, , .
, . , ,
.
/
. . , ,
, .
.
TDBGrid, TDBLookupComboBox.

TDBLookupComboBox, TDBGrid. ,
TTable (Tablel 2) TDataSource (DataSourcel DataSource2).
DataSourcel DataSource2 Tablel 2 . Tablel
Category MyData, 2 Items . , Tablel
(Category), 2 , (Items).

92

Borland C++ Builder 6.

DBGridl DataSource2. DBLookupComboBoxl


. ListSource
DataSourcel, ListField Category,
KeyField CategoryNo. , :
DBLookupComboBoxl DataSource
1
( Category), Category
( ),
DBLookupComboBoxl CategoryNo (
CategoryNo, ( KeyField),
.
, : Categor
Table] DataSourcel :
DBLookupComboBoxl, Items 2 Data
Source! DBGridl.
, Tablel 2.
2, ;
, MasterSource DataSourcel,
. <
, MasterField
Field Link Designer ( )
Available Indexes (
). , . ?
Items Primary ( ), Category ( ) ItemNDX ( ). Category.

__]

Swat
Descripsc

(tern
;
(Category JDescnpliorv .
*|
DfMM 64 Mb PC1 33. Infineon
5 1 69 pin. 54 bit
1
DIMM 64 Mb NCP
5 68 pin. 64 bit
DIMM 1 28 Mb PC! 33, POI original
5 60pm, 64 bit chip 'DIMM 1 28 Mb PC1 33, NCR
5 68 pin. 64 bit
DIMM 1 26 Mb PCI 33. Samsung original
5 : 63 pin. 5-1 bit 8 chip ..,;.
DIMM 1 28 Mb PCI DO. Transcend
5 rS16MLE?2V6XN.w
|
DIMM ?SG Mb PCI 33. Spectek
5 6 chips
DIMM 256 Mb PCI 33. M tec
5 68pm. 64 bit
.QIMM256MbPC133.PQI
5 68 pin. 54 bit
DIMM 256 Mb PCI 33. Samsung original
5 1 68 pin. 64 bit

LLJ
. 2.18.
(Field Link Editor)

jr

. 2.19. ,
.

TDBGrid
,

Available Indexes
. Detail Fields , . Category. Master Fields
. ,
Detail Fields Category, Master Fields CategoryNo,
Add.
Joined Fields (. . 2.18). -

2.

. MasterFields
CategoryNo.
, , . OnCreate :

void _fastcall TForml::FormCreate(TObject *Sender)


{
DBLookupComboBoxl->KeyValue=Tablel->
Field ByName("CategoryNo")->Value;
}
DBLookupComboBoxl. , . KeyValne
DBLookupComboBoxl ,
CategoryNo. CategoryNo
Tablel, .
, Active true, . . 2.19. ,
TDBGrid , .


BDE, , , ,
. (Cached Updates Mode)
, , ,
, .
,
, MB, ,
Dell.MB Del2.MB. ,
. .
BDE : (TDatabase), ( TQuery),
( TBDEClientDataSef).
.
,
TBDEClientDataSet. TDatabase (TQuery). TDatabase TBDEClientDataSet , .
,
CachedUpdates true.
( Post) ,
, ,
(, cache).
,
ApplyUpdates, CancelUpdates.

94

Borland C++ Builder 6.

ApplyUpdates ]
, , TDatabase, !
, ApplyUpdates CommitUpdate
CancelUpdates , ,
ApplyUpdates CancelUpdati
( ).
( 6asi
) - TI
.

. , ApplyUpdates
.
, ,
.
ApplyUpdates CancelUpdates
. ,
CachedUpdates true.
,
CachedUpdates false
( ). ,
UpdatesPending.
true, . , ,
( ) <
UpdatesPending. , CachedUpdates
true. UpdatesPending false, <
ApplyUpdates, ,
CancelUpdates . ,
, .
TBDEDataSet , :

typedef void
fastcall ( closure *TUpdateRecordEvent)
(Db::TDataSet* DataSet, Db::TUpdateKind UpdateKind,
TUpdateAction &UpdateAction);
typedef void
fastcall ( closure *TUpdateErrorEvent)
(Db::TDataSet* DataSet, b::EDatabaseError * E,
Db::TUpdateKind UpdateKind, TUpdateAction &Upd'ateAction) ;

, .. ApplyUpdates . OnUpdateRecord
TUpdateRecordEvent ,
, .
, ,
.

DataSet, OnUpdateRecord .
UpdateKind TUpdateKind, ,

2.

95

, . : ukModify ( ), uklnsert
( ) ukDelete ( ). .
- UpdateAction OnUpdateRecord. ,
UpdateAction TUpdateAction. : uaAbort ( ), uaApplied ( , . . ),
uaFail ( , ),
uaSkip ( , ).
uaRetry ( ), OnUpdateRecord.
, UpdateAction uaFail.
, , , , .
,
OnUpdateRecord UpdateAction uaApplied.
- , OnUpdateError. ,
throw, . :
OnUpdateRecord,
(, ) EDatabaseError. . OnUpdateError
- .
, ,
, . , TDBGrid, TTable TDataSource, , , . Tablel Items MyData.
, CachedUpdates
true. .
Q (TCheckBox) (TLabef). CBUpdatesPending
Caption. :
. .
, , .
Q () .
ButtonApply ,
ButtonCancel . , .
Q (TLabel). , : LIns
: 0, LDel : 0, LMod : 0, LErr : 0.
,
, .

96

Borland C++ Builder 6.

. 2.20.
,
;
CBUpdatesPending.
Post, AfterPost Table!
:
CBUpdatesPending->Checked=Tael->UpdatesPending;
Post CBUpdatesPending UpdatesPending.

* 1
r.t. . *

\
_

; :

jftem
1 Samsung 530
2 Samsung ML-1^10
3 Epson EPL-5900L

- "

4 Canon LBP-810
5 Brother HL-1 240 Mono Lase
6 Epson AcuLaser C1 OOOw
? EpsonAcul_oserC20GQ
8 HP LaserJet 1000
9 HP LaserJet ?200

iLd

|Cgp

'-.
1

; ni'! &:!}-"

""- - 1
-_ij
A4. GDI. 2 . 600 dpi, ppm, 1 50 -1
GDI. 8 . 600 dpi, ppm, 1 %'
4, GDI, 2(13) , 600 dpi, 12 ppm. -: :;:
4. GDL 600 dpi, 8 ppm, 1 00 . LF :.:.
4, 2&, 600x600 dpi, 1 2 ppm, 250 ;. - '..
4, , 1 6(256) . 600 dpi/2400 dpi RIT. \
4, , 84(512) , 600 dpi/2400 dpi RIT. , .
4. 1 , GDI. 600 dpi 1 D ppm, 2 |
4. 0(72) . 1?00 dpi, 1 4 ppm, 250

. 2.20.
, , ButtonApply ButtonCancel.
ApplyUpdates CommitUpdates.
, ,
- CancelUpdates.
CBUpdatesPending, CommitUpdates,
CancelUpdates . ,
, AfterPost.
ButtonApply ButtonCancel
, .
NDel, NIns, NMod NErr. Unitl.cpp,
:
TForml *Forml;
:

int NDel, NIns, NMod, NErr;


0 (
).
NDel, NIns, NMod NErr
OnUpdateRecord OnUpdateError. . , OnUpdateRecord UpdateKind ,
, 1. ,

2. BDE

97

UpdateAction uaApplied. OnUpdateError 1 NErr,


UpdateAction uaAbort.
bins, LDel, LMod LErr UpdateLabel. NIns, NDel, NMod NErr
Caption . , . , UpdateLabel
ButtonApply ButtonCancel.
- 2.7 2.8,
. 2.20.
2.5. CachedUpdates
11-

#ifndef UnitlH
define UnitlH
//-.
include <Classes.hpp>
include <Controls.hpp>
i nclude <5tdCtrls.hpp>
include <Forms .hpp>
include <DB.hpp>
include <DBGrids.hpp>
include <DBTables.hpp>
include <Grids . hpp>
i nclude <ExtCtrls.hpp>
include <DBClient.hpp>
include <DBLocal .hpp>
i nclude <DBLocalB.hpp>
include <Provider .hpp>
//..
class TForml : public TForm

published:
// IDE-managed Components
TDBGrid DBGridl;
TTable *Tablel;
TDataSource *Data5ourcel;
TButton *ButtonUpdate;
TButton *ButtonCancel;
TCheckBox *CBUpdatesPending;
TPanel *Panell;
TPanel *Panel2;
TLabel *LIns;
TLabel *Label2;
TLabel *LDel;
TLabel *LMod;
TLabel *LErr;
void
fastcall ButtonUpdateClick(TObject Sender)
void
fastcall ButtonCancelClick(TObject Sender)
void
fastcall TablelAfterPost(TDataSet *DataSet)
void fastcall TablelUpdateRecord(TDataSet DataSet,
TUpdateKind UpdateKind, TUpdateAction &UpdateAction);
void
fastcall TablelUpdateError(TDataSet *DataSet,
EDatabaseError *E, TUpdateKind UpdateKind,
4 . 319

98

Borland C++ Builder 6.

TUpdateAction &UpdateAction) ;
void _ fastcall FormCloseQuery(TObject *Sender, bool &CanClose)
private: // User declarations
void _ fastcall UpdateLabel(void) ;
public:
// User declarations
_ fastcall TForml (TComponent* Owner);
extern PACKAGE TForml *Forml;
//--#endif
2.6. CachedUpdates

#include <vcl.h>
#pragma hdrstop
#include "Unitl.h"

#pragma package(smart_ini t)
#pragma resource "*.dfm"
TForml *Forml;
int NDel, NIns, NMod, N E r r ;
_fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
NDel=0; NMod=0;
NIns=0; NErr=0;
void _ fastcall TForml: :ButtonUpdateClick(TObject Sender)
{
Tablel->ApplyUpdates() ;
Tablel->CommitUpdates() ;
CBUpdatesPending->Checked=Tablel->UpdatesPending;
UpdateLabeK) ;
void _ fastcall TForml : :ButtonCancelClick(TObject *5ender)
{
Tablel->CancelUpdates() ;
CBUpdatesPending->Checked=Tablel->UpdatesPending;
UpdateLabeK) ;
void _ fastcall TForml : :TablelAfterPost(TDataSet *DataSet)
{
CBUpda te s Pending->Checked=Tabl el ->Updates Pending;
void _ fastcall TForml : :TablelUpdateRecord(TDataSet *DataSet,
TUpdateKind UpdateKind, TUpdateAction &UpdateAction)

2. BDE
UpdateAction=uaApplied;
switch(UpdateKind)
case ukModify:
{ NMod++; break; }
case uklnsert:
{ NIns++; break;}
case ukDelete:
{ NDel++; break; }
void

void

fastcall TForml::TablelUpdateError(TDataSet *DataSet,


EDatabaseError *E, TUpdateKind UpdateKind,
TUpdateAction &UpdateAction)
NErr++;
UpdateAction=uaAbort;
fastcall TForml::UpdateLabel(void)
15->=" : " + IntToStr(NIns);
NIns=0;
1->11=" : " + IntToStr(NDel);
NDel=0;
1->=" : " + IntToStr(NMod);
NMod=0;
LErr->Caption="Oujn6oK : " + IntToStr(NErr);
NErr=0;

void

fastcall TForml::FormCloseQuery(TObject *Sender, bool &CanClose)


if((Tablel->CachedUpdates) && (Tablel->UpdatesPending))
swi tch(Application->MessageBox(
" ! ?",
"!", MB_YESNOCANCEL + MB_ICONQUESTION))
case IDYES:
{ Tablel->ApplyUpdates();
Tablel->CommitUpdatesO ;
break;}
case IDCANCEL:
{ CanClose=false;
break; }
case IDNO:
{ Tablel->CancelUpdates();
break; }

99

100

Borland C++ Builder 6.


. , RevertRecord
, !
UpdateObject - TUpdateSQL,
, . . !
, Using the BD
to cache updates C++ Builder.


(Database Desktop ), ,
.
, , SQL. BDI
.
,
, . AddAlia
TSession. Session TSession ,
, BDE. !
TSession . STANDARL
(Paradox, dBASE, ) AddStandardAlias
TSession, AddAHas. , MyDatal
Paradox :
if ( ! S e s s i o n - > I s A l i a s ( " M y D a t a l " ) ) S e s s i o n - > A d d S t a n d a r d A l i a s (
"MyDatal", " D : \ \ M y D a t a l " , "PARADOX");

AddStandardAlias ,
, .
AnsiString : "PARADOX"
"DBASE", "ASCUDRV" ( ).
, ,
IsAlias TSession.
, . !
, true.
new.
, delete:
* Tablel= new T T a b l e ( t h i s ) ;
delete(Tablel);

,
:

Tablel->DatabaseName="MyDatal";
Tablel->TableName="Itemsl.db";
Tablel->TableType=ttParadox;

. -

2.

101

FieldDefs IndexDefs . , Clear.


FieldDefs, AddFieldDef, TFieldDef.
, ,
. Item:

NewFieldDef->Name="Item";
NewFieldDef->DataType=ftString;
NewFieldDef->Size=50;
NewFieldDef->Requi red=true;
.
MQToaAddlndexDef, TIndexDef.
. ,
ItemNo:

NewIndexDef->Name="<Primary>";
NewlndexDef->FieIds="ItemNo";
NewIndexDef->Options=TIndexOptions() ixPrimary i x U n i q u e

CreateTable. 2.7 Item, .
2.7. Item

Table* Tablel= new TTable(this);


if (!Session->IsAlias("MyDatal"
Session->AddStandardAlias("MyDatal", "D:\\MyDatal", "PARADOX");
Tablel->DatabaseName="MyDatal";
Tablel->TableName="Itemsl.db";
Tablel->TableType=ttParadox;
Tablel->FieldDefs->Clear();
Tablel->IndexDefs->Clear();
TFieldDef* NewFieldDef=Tablel->FieldDefs->AddFieldDef();
NewFieldDef->Name="ItemNo";
NewFieldDef->DataType=ftAutoInc;
NewFieldDef=Tablel->FieldDefs->AddFieldDef();
NewFieldDef->Name="Item";
NewFieldDef->DataType=ftSt ing;
NewFieldDef->Size=50;
NewFieldDef->Requi red=true;
NewFieldDef=Tablel->FieldDefs->AddFieldDef();
NewFieldDef->Name="Category";
NewFieldDef->DataType=ftlnteger;
NewFieldDef->Requi red=true;
NewFieldDef=Tablel->FieldDefs->AddFieldDef();
NewFieldDef->Name="Description";

102

Borland C++ Builder 6.

NewFieldDef->DataType=ftString;
NewFieldDef->Size=100;
NewFieldDef=Tablel->FieldDefs->AddFieldDef();
NewFieldDef->Name="Index";
NewFieldDef->DataType=ftString;
NewFieldDef->Size=5;
NewFieldDef->Requi red=true;
NewFieldDef=Tablel->FieldDefs->AddFieldDef();
NewFieldDef->Name="Price";
NewFieldDef->DataType=ftCurency;
NewFi eldDef->Required=true;
TIndexDef* NewIndexDef=Tablel->IndexDefs->Add!ndexDef();
NewIndexDef->Name="<Primary>";
NewIndexDef->Fields="ItemNo";
NewIndexDef->Options=TIndexOptions() ixllnique;
NewIndexDef=Tablel->IndexDefs->AddIndexDef();
NewIndexDef->Name="ItemNDX";
NewIndexDef->Fields="Item";
NewIndexDef->Options=TIndexOptions() ixUnique;
Tablel->CreateTable();
delete(Tablel);
BDE
, TSession, TDatabase, TQuery,
(Data Controls),
.

BDE
.
, .
: / , , , , . ,
TDataSource TField.
, TDataSource !
, , ..
(Dynamic)
(Persistent) . , .
, . , (Calculated)
(Lookup Fields).

(Master/Detail), ,
, .. .

BDE
()


TDataba.se TSession

SQL
TQuery
TUpdateSQL TBatchMove

Borland Database Engine


(BDE) . .
TDataSmirce TField. BDE. , TDataSet TQuery. TQuery ,
. TQuery, SQL, TSession, TDatabase, TUpdateSQL, TBatchMove,
(TDataModule) (TBDECHentDataSet).
, , .


( TDataModule) ,
. ,
,
.
, (,
, ).
.
, TDataSource,
TQuery, TDatabase, TSession, TStoredProc
.. Data Access,

104

Borland C++ Builder 6.

, (BDE, dbExpress, ADC


InterBase). ,
, , , TTimer, TOpenDialog, TSaveDialo^
Dialogs.
,
,
- . ]
,
(-) ,
.
, TDataSource , ,
: !^
, ,
. ,
TDataSource, . ,
, ,
,
. -
, .
, Data Module
File \ New. C++ Builder 6 , +
Builder 4 (. . 3.1). /
,
, (Diagram).
C++ Builder Diagram
, Object TreeViev
.

. 3.1.
Umtl cpp UniG.cpp j
lUnliltedl

3 J

Modified

ii

li J
:
'Insert
\Umt2 '- 1

h ADiagretri./

. .2. (Diagram), , Master/Detail

3. BDE ()

105

, ,
. Include Unit Hdr
File.
->__, ,
DModl->Tablel. . ,
,
,
Diagram .
. 3.2 , Master/Detail
Category Items.
, : OnCreate OnDestroy. TNotifyEvent.
. OnCreate , , .
OnDestroy : , ..
-
.
'


TDatabase
BDE

TDatabase. TDatabase
,
DatabaseName .
, TDatabase,
. TDatabase
- .
, MyData TDatabase, , BCDEMOS,
TDatabase. TDatabase
Database, TDBDataSet.
,
Edit]
TDatabase :

Editl->Text=Tablel->Database->DataSetCount;
, MyData Tablel
2, Editl 2.

106

Borland C++ Builder 6.

, BI
TDatabase.
,
, ,
.

TDatabase
TDatabase >
(alias). !
( SQL Explorer BDE Administrator),
, AliasName.
DatabaseName
DatabaseName
.
. ^
, DriverName,
. , STANDARD ( Paradox dBASE), INTRBASE (:
InterBase) . . , , !
DatabaseName ,
( TQuery) . AliasName
- , , AliasName Driver
Name .
.
DriverName,
, TDatabase.
Params, ( TStrings).
Params
=. , >
(. . )
, Params , .
. STANDARD (Paradox dBASE)
INTRBASE MSACCESS :
PATH=d:\MyData
SERVER NAME=d:\IBase\MyIBase.gdb
DATABASE N A M E = d : \ D a t a \ N o r t h w i n d . m d b

//STANDARD
//INTRBASE
//MSACCESS

, .
, Params
, ,
, . .
ODBC
SQL Links, BDE. ,
SQL, , , .

3. ()

107

. 3.3. Params TDatabase


(Value List editor)
Params, TString,
(Value List editor).
Params. , . Key
, Value (.
. 3.3). Code Editor...,
, ,
( =,
, ).
TDatabase ,
. , . . 3.4 TDatabase photodatabase.gdb
INTRBASE, Temp D:.
TDatabase Name, Alias Name Driver Name.
TDatabase DatabaseName, AliasName DriverName.
DatabaseName Name (
).
( Alias Name), ( Driver Name),
, .

j-jMyOOB
Eammeler overrides
SERVER NAME'd\Temp\photodatabase gdb
USER NAME-SYSDBA
P*SSWORD=rrmsterkey

Login prampt
17 beep inactive connection

. .4. TDatabase
photodatabase.gdb INTRBASE

108

Borland C++ Builder 6.

TDatabase MEMO, c<


. ,
(Parameter overrides), Params 061
TDatabase. (
, ). ,
:
. , ;
(
TDatabase). Driver Name,
Defaults. Parameter oven
ides
, .
(,
, ,
.
.
Login prompt Keep inactive connection.
LoginPrompt KeepConnection .
LoginPrompt ,
.
true,
false, .
LoginPrompt false, :
, Params ;
TDatabase ( ).
, TDatabase '
.
TDatabase , (.
). TDatabase !
Connected. Connected true
, false,
. , Opei
Close .
TDatabast
,
( DatabaseName ). }
, , !
: ? ? KeepConnection
true, ,
() . TDatabase . !
,
.
TDatabase ,
. DataSets DataSetCount (. . ) ,

3. ()

109

TDatabase. . DataSetCount , a DataSets ( TDBDataSei). , DataSetCount DataSets:

Memol->Clear();
for (int i = 0; i < Databasel->DataSetCount; i++)
{
TTabTe* MyTable;
MyTable=dynamic_cast<TTable *>(Databasel->DataSets[i]);
if(MyTable) Memol->Lines->Add(MyTable->TableName);
}
,
(Memo!), TDatabase (Database!) . .
, Memol.
, Database!. * (. . ,
). , Memol
, .
Locale ,
TDatabase. .
IsSQLBased ,
TDatabase ODBC SQL Links. InTransaction
. true ,
. , .
,
TDatabase , TDatabase
. HandleShared.
TDatabase ,
true.


{Transaction)
( ). , ,
. , , , , , , , .
, , , . . , , ,
( ).
( ),

110

Borland C++ Builder 6.

( ). ().
. />- ( ),
. .
Q (Atomicity). , , .
Q (Consistency). .
Q (Isolation). () .
LI (Durability). , , . .
BDE
. , , .
,
.
(,
, ), , TDatabase.
( )
TDatabase . ,
, StartTransaction. Commit , Rollback .
try...catch.
. StartTransaction TDatabase.
try
. Commit .
- , catch Rollback
. ,
(cached updates):

Databasel->StartTransaction() ;
try
{
Tablel->ApplyUpdates()
;
Databasel->Commit() ;
}
catch (...)
{
Databasel->Rollback() ;
throw;
}
Tablel->Commi tUpdatesQ ;

3. ()

, Rollback throw . ,
CommitUpdates, .
Tramlsolation TDatabase.
TTranslsolation.
:
tiDirtyRead .
, .
Q tiReadCommitted SQL.
(committed) .
Q tiRepeatableRead' .
, .

STANDARD (Paradox, dBASE), tiDirtyRead.
(ASCIIDRV) .



GetTableNames GetFieldNames TDatabase.
:

void

fastcall GetTableNames(Classes::TStrings* List,


bool SystemTables = false);
void fastcall GetFieldNames(const AnsiString TableName,
Classes::TStrings* List);
GetTableNames
(TStrings*). TStrings
, , TDatabase.
(. . Connected
false). SystemTables . true,
. (, Microsoft Access, Interbase
.) ()
. SystemTables ,
.
GetFieldNames . ( AnsiString)
. TString* (
).
.
, GetTableNames GetFieldNames,
.
( TListView).
( File->New->Data Module)
TDatabase. ,
DModl ( Name). Database! MyData (
- ).

112

Borland C++ Builder 6.

Database! Forml, ]
. Include Unit Hdr MI
File. ,
(Unit2) . (Unitl) erpi
^include "Uni2.h". , .
ListViewl, ,
. ,
OnCreate:

void
{

fastcall TForml::FormCreate(TObject *Sender)


DModl->Databasel->GetTableNames(ListBoxl->Iterns);
ListBoxl->ItemIndex=0;
DModl->Databasel->GetFieldNames(
Li stBoxl->Iterns->Strings[ListBoxl->ItemIndex],
ListBox2->Items);

}
GetTableNames,
Items ListBoxl ,
Database!'. ( 0)
GetFieldNames, Items ListView2
, (. . ,
). , Database!
-> DModl.
Category

EmployeeNo
LNome
FName
Suppliers
MNome
HireDtfe
FireDeta
Description
Photo
Birthday

. .5.
GetTableNames GetFieldNames
ListView.
ListViewl.
OnClick TListView. 1
, ;
. OnClick
ListViewl :

void
{

fastcall TForml::ListBoxlClick(TObject *Sender)


DModl->Databasel->GetFieldNames(
ListBoxl->Items->Strings[ListBoxl->ItemIndex] ,
ListBox2->Items) ;

3. BDE ()

113

, ,
(. . 3.5).

, :
Access violation at address 00407C59 in module 'PROJECT! F.XE'. ,
OnCreate
DModl.
. , . Options Project.
Project Options Forms.
(Auto-create forms). Form? - , FormJ. ,
DModl .
.
Project View Source. ^
Project).. CreateForm Application.
, :

Application->CreateForm( classid(TDModl), &DModl);


Appl1cation->CreateForm( classld(TForml), &Forml);

TDatabase
TDatabase ,
. TDatabase OnLogin. BeforeConnect, AfterConnect,
BeforeDisconnect AfterDisconnect TCustomConnection, TDatabase.
TNotifyEvent, OnLogin :

typedef void
fastcall ( closure *TDatabaseLoginEvent)
(TDatabase* Database, Classes::TStrings* LoginParams);
OnLogin ,
, LoginPrompt true
( ). ,
, , , Params TDatabase.
LoginParams, TStrings. ,
OnLogin INTRBASE:

void

fastcall TForml::DatabaselLogin(TDatabase *Database,


TStrings *LoginParams)
LoginParams->Add("USER NAME=SYSDBA");
LoginParams->Add("PASSWORD=masterkey");

114

Borland C++ Builder 6.

OnLogin ,
Params ,
.
BeforeConnect AfterConnect
. - , . ,
,
BeforeConnect Params
TDatabase.
, .
, .

void
{

fastcall TForml::DatabaselBeforeConnect(TObject *Sender)


Databasel->Params->Clear();
Databasel->Params->Add("SERVER NAME=" + DBName);
Databasel->Params->Add("USER NAME=" + UName);
Databasel->Params->Add("PASSWORD=" + PWord);

}
BeforeDisconnect After Disconnect,
,
, , .


TSession
, TDatabase
, TSession , ( TDatabase), .
TSession, , (TDatabase).
:
Q , (, , , . .);
Q
;
G OnPassword OnStartUp TSession;
Q Paradox (NetFileDir) (PrivateDir) ;
Q Paradox, .
TSession. , ( TDatabase ).
, , ,
TDatabase. Object TreeView Default,

3. BDE ()

115

TSession. ,
(, ),
Session TDatabase.
TSession Session.
TSession , , BDE ,
. TSession, . , , ,
. ,
(Threads),
TSession.
,
TSession.

TSession
TSession,
( Name) ( SessionName).
,
. SessionName.
,
(Default).

. , ,
Session, Default.
, TSession. , .
, , .
Object TreeView.
,
SessionName .
TSession , . T:vm& AutoSessionName.
true, BDE
( SessionName).
, _ . , Session! Session!_1. ,
, TSession .
AutoSessionName true, SessionName ( TDataSet)
(TDatabase) . , ,
AutoSessionName true.
. -

116

Borland C++ Builder 6.

,
TSession ( Default
). , TSession
AutoSessionName
true. ,
SessionName,
.
KeepConnections ;
KeepConnection
. KeepConnection TDatabase ]
, . SQLHourGlass (
, :
. , , .
true, SQL, BDE
SQL- .
.
NetFileDir Paradox
PDOXUSRS.NET, BDE Paradox. ,
Paradox. PrivatDir , BDE .
BIN , C++ Builder.
, , Active true. , Open.
PrivateDir, NetFileDir,
ConfigMode. Active,
false, Close. , ,
.
. , .
, , .
TSession
Databases DatabaseCount. ,
, . ,
, Sessionl :
Sessionl->Active=true;
for (int i = 0; i < Sessionl->DatabaseCount; i++)
Sessionl->Databases[i]->Active = true;
, , (, , ) .
TSession . OnStartup
Active false true.

3. ()

117

, , , . OnPassword
Paradox, . ,
BDE Paradox,
.
OnPassword (,
AddPaSsword TSessiori). Sender
TObject, OnPassword
Continue. true, BDE, .
OnPassword , BDE
. Paradox dBASE, , .

OnPassword Sender,
TObject. , TSess/on,
,
.


Paradox dBASE
Paradox dBASE . SQL Explorer Database Desktop. , Paradox Database Desktop,
( Restructure Table)
Password Security Table properties. , Define, Modify.
Master pass word Verify master password.
Delete , Change . Auxiliary Passwords
, ,
, , ..

. 3.6.
,
, .
TSession ,
Paradox dBASE.

118

Borland C++ Builder 6.

, TSession
, , BDE
. '
, ,
. TSession ,
(. . 4.6).
( Add), ( Remove)
, TSession (Remove all). BDE
OnPassword, .
- -
AddPassword. AnsiString,
. AddPassword ,
. , Session! . ( ) ,
Passl, Pass2, Pass3 Pass4 . , , , OnPassword
:

void
{

fastcall TForml::SessionlPassword(TObject *Sender, bool &Continue)


Sessionl->AddPassword("Passl")
Sessionl->AddPassword("Pass2")
Sessionl->AddPassword("Pass3")
Sessionl->AddPassword("Pass4")
Continue=true;

}
, true Continue, ,
.
A ddPassword OnPassword.
, , , ,
AddPassword ,
.

TSession, .
RemovePassword RemoveAllPasswords. Remove? assword
AnsiString, TSession.
AddPassword.
RemoveAllPasswords ,
TSession. .
, , ,
,
.

3. BDE ()

119

, . GetPassword,
. OnPassword .
, ,
. GetPassword true, ,
false, Cancel. GetPassword
, TSession
, .


TSession , . , .
AddAlias viAddStandardAlias , (, BDE Administrator)
BDE, , .
AddA lias :
void

fastcall AddAlias(const AnsiString Name,


const AnsiString Driver, Classes::TStrings* List);

Name Driver , ,
. AddAlias TStrings. TStrings
, TStringList. List , , ,
..
,
employee.gdb INTRBASE. ParList
TStringList. try . SER VER NAME,
, USER NAME PASSWORD. .
DBGridl DataSourcel, Tablel. Tablel MySession
( SessionName), ( DatabaseName)
Sales ( TableName). Open
DBGridl .
void
{

fastcall TForml::ButtonlClick(TObject *Sender)

TStringList *ParList = new TStringList();


try
{
ParList->Add("SERVER NAME=d:\\Temp\\employee.gdb");
ParList->Add("USER NAME=SYSDBA");
ParList->Add("PASSWORD=masterkey");
Sessionl->AddAlias("MyIntrbase", "INTRBASE", ParList);

120

Borland C++ Builder 6.


}
{

fj n a 11

delete(ParList);

DBGridl->DataSource=DataSourcel;
DataSourcel->DataSet=Tablel;
Tablel->SessionName="MySession";
Tablel->DatabaseName="MyIntrbase";
Tablel->TableName="Sales";
Tablel->0pen();

, . ,
.
, , , .
IsAlias TSess/on. ,
, true.


ConfigMode TSess/on.
: cfmVirtual ( ,
, , ); cfmPersistent (

); cfmSession ( , ). .
AddAHas
SQL. STANDARD (Paradox, dBASE ) AddStandardAlias. ,
AnsiString. , .
: Paradox, DBASE ASCIIDRV.
DeleteAlias .
. ModifyAlias , . AnsiString . TStringList*
. ,
TStringList.
, BDE
. BDE, SaveConfigFile. ,
BDE ,
, BDE, -

3. BDE ()

121

. , ConfigMode TSession cfmSession, , ,


.
, SQL.
TSession : AddDriver,
DeleteDriver ModifyDriver. .
C++ Builder.
, , TDatabase.
FindDatabase, OpenDatabase, CloseDatabase DropConnections. FindDatabase AnsiString,
TDatabase, TSession.
DatabaseName , ,
TDatabase. , NULL. FindDatabase
TDatabase,
.
OpenDatabase , , TDatabase.
. OpenDatabase
FindDatabase, TDatabase . , TDatabase.
Open , , OpenDatabase .
TDatabase DeleteDatabase.
, DatabaseName , . , , . , , DropConnections , .
, KeepConnections true.
, TSession, ,
, .


TSession , Get. , , , , , . TStringList*, .
' , TStringList ,
, .
, TStringList* (TString*).

122

Borland C++ Builder .

void
void
void

fastcall GetAliasNames(Classes::TStrings* List);


fastcall GetDatabaseNames(Classes::TStrings* List);
fastcall GetDriverNames(Classes::TStrings* List);

, . , ,
:

TStringList *MyList=new TStringList();

try
{

Sessionl->GetAliasNames(MyLi st);
Li stBoxl->Items=MyList;
Li stBoxl->ItemIndex=0;

fi n a 11

delete MyLfst;

}
, , TStringList,
,
Session 1. ,
Items ListBoxl, . ListBoxl.
TStringList , .
Get ,
TStringList* (TString*), :

void

fastcall GetAliasParams(const AnsiString AliasName,


Classes::TStrings* List);
void
fastcall GetDriverParams(const AnsiString DriverName,
Classes::TStrings* List);
void
fastcall GetStoredProcNames(const AnsiString DatabaseName,
Classes::TStrings* List);
void
fastcall GetTableNames(const AnsiString DatabaseName,
const AnsiString Pattern, bool Extensions, bool SystemTables,
Classes::TStrings* List);
void
fastcall GetFieldNames(const AnsiString DatabaseName,
const AnsiString TableName, Classes::TStrings* List);
, .
List , , ,
,
.
GetTableNames .
List DatabaseName. , GetTableNames. Pattern
.
Pattern , . Extensions

3. ()

123

true, Paradox dBASE .


true SystemTables ,
( ).
, GetFieldNames, , List .
.

TComboBox. , TListBox,
. ( TLabef),
: :, : :.
TSession.
. ListBoxS Labels Visible false, .

Items TComboBox String List Editor
: , .
. ComboBoxl
ListBoxl viListBox2 ( viListBox3). ,
ListBoxl ListBoxl ,
, ListBoxS. ListBox3 , ComboBoxl .
,
.
3.1 3.2 GetSessionlnfo, .
3.1. GetSessionlnfo

//

#ifndef UnitlH
#defme UnitlH
//
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DBTables.hpp>
//
class TForml : public TForm
{
published:
// IDE-managed Components
TListBox *ListBoxl;
TSession *Sessionl;
TComboBox *ComboBoxl;
TLabel *Labell;
TListBox *ListBox2;
TLabel *Label2;
TListBox *ListBox3;
TLabel *Label3;

124

Borland C++ Builder 6.

void _ fastcall FormCreate(TObject *Sender) ;


void _ fastcall ComboBoxlChange(TObject *Sender)
void _ fa'stcall ListBoxlClick(TObject *Sender) ;
void _ fastcall ListBox2Click(TObject *Sender) ;
private: // User declarations
public:
// User declarations
_ fastcall TForml(TComponent* Owner);
extern PACKAGE TForml *Forml;
//
#endif
.2. GetSessionlnfo

#include <vcl.h>
#pragma hdrstop
#include "Unitl.h

#pragma package(smart_ini^t)
#pragma resource "*.dfm"
TForml *Forml;
_fastcall TForml : :TForml (TComponent* Owner)
: TForm(Owner)

void _ fastcall TForml : :FormCreate(TObject *Sender)


{
ComboBoxl->ItemIndex=0;
Width=336;
ComboBoxlChange(NULL) ;
ListBoxlClick(NULL) ;

void _ fastcall TForml : :ComboBoxlChange(TObject *Sender)


{
TStringList *MyList=new TStri ngLi st () ;
try
{
switch (ComboBoxl->ItemIndex)
{
case 0: //
{
Sessionl->GetAliasNames(MyList) ;
ListBox3->Visible=false;
Label3->Visible=false;
Width=330;
break;

3. ()

125

case 1: //
{
Sessionl->GetDri ve r Names (My Li st) ;
Width=330;
ListBox3->Visible=false;
Label 3->Visible=false;
break;
}
case 2: //
{
Sessionl->GetDatabaseNames(MyList) ;
Width=495;
ListBox3->Visible=true ;
Label3->Visible=true;
break;
Li stBoxl->Items=MyLi st ;
ListBoxl->ItemIndex=0;
Label!- >Caption=ComboBoxl->I terns- >St rings
[ComboBoxl->ItemIndex]+" : " ;

}
_ finally
{
delete MyList;
}
ListBoxlClick(NULL) ;
>
//
-----------------------------------------------------------------void _ fastcall TForml : : ListBoxlClick(TObject *Sender)
I
TStringList *MyList=new TStringListO ;
try
{
swi tch(ComboBoxl->ItemIndex)
{
case 0: //
{
Sessionl->GetAliasParams (Li stBoxl->I terns- >
5trings[ListBoxl->ItemIndex] , MyList) ;
Label2->Caption="napaMeTpbi: " ;
break;
}
case 1: //
{
Sessionl->GetDriverParams(Li s tBoxl->I terns- >
Strings[ListBoxl->ItemIndex] .MyList) ;
Label2->Caption = "riapaMeTpbi: " ;
break ;

126

Borland C++ Builder 6.

case 2: //
{
Sessionl->GetTableNames(Li stBoxl->I terns ->
Strings[ListBoxl->ItemIndex] ,
"" , false, false, MyList) ;
Label2- >11=": " ;
break;
ListBox2->Items=MyList ;
ListBox2->ItemIndex=0;

}
_ fl n a 1 1
{
delete MyList;
}
if (ComboBoxl->ItemIndex == 2) ListBox2Click(NULL) ;
}
// ----------- .
void __ fastcall TForml: :ListBox2Click(TObject *Sender)
{
i f (ComboBoxl->ItemIndex != 2) return;
TStringList *MyList=new TStringLi st () ;
try
{

Sessionl->GetFieldNames (Li stBoxl->I terns- >


Strings [ListBoxl->ItemIndex] ,
ListBox2->Items->Strings[ListBox2->ItemIndex] ,
MyList) ;
ListBox3->Items=MyList ;
ListBox3->ItemIndex=0;

}
_ fi n a 1 1
{
delete MyList;

GetSessionlnfo
OnCreate Forml.
ComboBoxl. ,
, . :
ListBoxl , ListBox2
. , ListBoxS, Labels , .
Width 330.
, OnChange ComboBoxl OnClick ListBoxl.
ListBoxl , ListBox2.

3. ()

127

3.2, , TListBox, . ComboBoxl


OnChange.
OnClick ListBoxl. , OnClick ListBoxl (
ComboBoxl Change), (
). (
ComboBoxl )
OnClick ListBox2. .
OnClick OnChange,
, .
MyList TStringList. try ComboBoxl.
, MyList, ,
ListBoxS LabelS, Label 1
Label2. MyList Items TListBox, .
, , .
. 3.7.

DefauUDO
IBLocel
MyOata
MvOotol
MS Access
:unl FoxPro
& Visual FoxPro
dSASE

. .7. GetSessionlnfo

GetSessionlnfo, , . ,
, .
, . . - ,

TSession, .

GetAliasDriVerName
GetConf/'gParams.
.
.
C++ Builder .

128

Borland C++ Builder 6.



, ,
, . , -
, -
Data-Aware Controls ( Data Controls).
Data Controls . , ;
,
. , .
Data Controls , Standard. ,
TEdit TDBEdit, TLabel TDBText, ..
, Data Controls
DataSource. ,

, .
, .
Data Controls
. , TDBGrid TDBCtrlGrid,
. ( TDBGrid). , , ,
. , . ,
, (, , . .), (TDBGrid). , . ,
, .
, . ,
(TDBCheckBox), TDBImage,
Memo TDBMemo . .
.
, , ( TDBGrid).


,
()
. Data Controls :
TDBText, TDBEdit, TDBMemo, TDBImage, TDBCheckBox TDBRichEdit.

3. ()

129

, .
DataSource ( TDataSource),
, .
DataField, .
, , ,
.
, . (Field Editor),
, .
-
. TDBNavigator,
Data Controls, - (First, Last, Next . .).
,
, . .
, , TDBEdit , ; TDBText ; TDBRichEdit
, . .
Data Controls
TDBNavigator ( ).
, .
, , ,
.
TDataSource. VisibleButtons. (Set)
,
(, nbFirst, nbPrior . .). , false. ,
.

. 3.8. .
TDBNavigator Employee
5 .319

130

Borland C++ Builder 6.

. 3.8
. ( TDBNavigator).
, TDBGrid. ,
, .

Data Controls ,
,
. (TDBListBo)
TDBLookupListBox), (TDBComboBox TDBLookupComboBox
(TDBRadioGroup).
TDBListBox, , ,
Items. DataSource DataField TDBListBo)
().
, !
.
.
TDBLookupListBox. 5
TDBLookupListBox , TDBListBox.
, TDBLoohipListBox Items.

ListSource ListField. ListSource TDataSource,
,
. (Lookup Table)
ListField.
, ,
.
TDBLookupListBox, ?
, KeyField.
, .
KeyField (
). , ;
TDBLookupListBox Category,
. ListField (
Category, KeyField CategoryNo, \
. , ,
.
,
TDBLookupListBox DataSource DataField.
, TDBLookupListBox
. , DataField, ,
KeyField, )
. KeyField
, DataField
.

3. ()

131

(
Category), TDBLookupListBox
Items. DataField Category,
Category. ,
TDBLookupListBox ,
Category Items Category. Items,
- .

TDBLookupListBox ,
: ListSource, ListField, KeyField, DataSource
DataField. ,
,
TListBox, , TDBListBox.
TDBComboBox
TDBLookupComboBox. TDBComboBox , Items,
TDBLookupComboBox ( ListSource, ListField KeyField).

.
,
-
TDBRadioGroup.
DataSource DataField,
Items. , Columns. 1, . .
. Values TString
, Items.
Values , DataField.

( TDBChart)
TDBChart , . TDBChart , Data Controls.
, (. .
3.9),
.
, .
:

(, , ..).
, , .

132

Borland C++ Builder 6.

. ,
TDBChart.
,
MyData . Storage,
. Storage !
3.1.
3.1. Storage
Tun
(Type)

(Size)

StoreltemNo

Autoincrement (+)

Item

Long Integer (I)

Yes

No
No

(Field Name)

Qty

Short (S)

Description

Memo (M)

240

(Key)
*

(Required)

Yes

, Storage . StoreltemNo
, Item , <
Items. Qty
. , *
(. .
). Description
, , .. )
Storage Items Item ItemNo.
Database Desktop,
. Storage ,
() MyData.

Format. | General | Mtrts Do Source |

labels: (C

. .9. ( TDBChart)

Storage Item; Qty, .


Item Items.
Item TBatchMove,
. TBatchMove .

3. ()

133

.
TBatchMove. Tablel Storage
MyData, 2 Items . Active true.
, Source BatchMovel 2,
Destination Tablel. ,
Items Storage.
Mappings :
Item=IternNo
Mappings -,
. -
, -
.
(TButton), OnClick
:
BatchMovel->Execute();
,
BatchMovel, Item Storage.
Qty , , , .
.
OnClick :
randomizeO ;
Tablel->First() ;
while (!Tablel->Eof)
{
Tablel->Edit() ;
Tablel->FieldByName("Qty")->Value=random(100);
Tablel->Post();
Tablel->Next();
}

Qty Storage 0 100. , ,


,
Storage, Data.
TDBChart.
TDBChart,
, . TQuery BDE. ,
. DatabaseName Query 1 MyData.
SQL :
SELECT Category.Category, Sum(Storage.Qty*Items.Price) AS Cost
FROM (Items INNER JOIN Category ON Items.Category =

134

Borland C++ Builder 6.


Category.CategoryNo) INNER JOIN Storage ON Items.ItemNo = Storage.Item
GROUP BY Category.Category;

, SQL.
(Category, Items Storage),
(.. , ).
Category , Storage
, . Items ,
Category Storage. SQL , TQnery. Active Query! true.
DBChartl. .
Chart ( ) ,
Series. ,
. . Add,
TeeChart Gallery Pie
. Seriesl.

. 3.10. ,

, Series.
Data Source Dataset. Data Source
(. . 3.9). Dataset
Query 1. Labels Category, Pie Cost. ,
Cost ( ),
Category.
, , .
Marks Style Label and Percent.
Chart Titles.
TDBChart - . , .
, .
Legend Visible. Etce, (. . 3.10).

3. BDE ()

135

TDBCtrlGrid
TDBCtrlGrid, TDBGrid,
. -. TDBGrid
, TDBCtrlGrid
. (TDBEdit, TDBImage ).

. 3.11. TDBCtrlGrid
TDBCtrlGrid , (. . 3.11).
,
. TDBCtrlGrid
DataSource.
, .
.
(. . 3.12).
. TDBNavigator, .
TDBCtrlGrid
. ,
.
,
( , ).

. 3.12. TDBCtrlGrid

136

Borland C++ Builder 6.

TDBCtrlGrid
.
G ColCount RowCoimt.
ColCount 1, RowCount 3. '
, 3 .

.
Q Orientation. ( ).
Q AllowDelete Allowlnsert. !
.

( TDBGrid)
Data Controls,
, TDBGrid. ,
. TDBGrid ( )
, . . .
, ( )
, ,
.

, .
- Columns,
.

Columns. TColumn
Columns TDBGridColumns
TColumn. TColumn
. Columns TColumn,
.
( TColumn) (Column Editor).
, Columns (. .
3.13).
TColumn, . ,
.
, TColumn , BDE - ,
.
TColumn,
. TColumn, Ins ,
Add New ( ),
Add .
: 0 TColumn. 0 ( 1, 2,

3. ()

137

3 ..) TColumn TDBGridColumns. - .

0 - Cetegoiy
1 -Item

"

. 3.13. TColumn
, -. , , FieldName.
TColumn .
. ,
-.
TColumn
, ,
.
.
Color, Font.
Alignment (,
).
Title TColumn.
- Title TColumnTitle. ,
.
, .
Caption. Title
, . . 3.13 , TColumn. , .
, . 3.14.
|

Samsung ML-

j *j

18900 ^

Samsung ML-121Q

20300 .

Epson EPL-5900L

239 00

^ MH | LBP-81 0
Brother HL-1240 Mono Loser

l.[nn

215QO
26

Epson AcuLaser C1 000

1.34900

Epson AcuLaser C2QOO

2,15500

HP LaserJet 100Qw

22-1 OOt =

HP LaserJet! 200

332.00*

HP Laser Jen 220

44000*

= HP LaserJet 3200

637 00|

. 3.14.
TDBGrid, ,
; ,

138

Borland C++ Builder 6.

. Readonly TColumn tru


.
TColumn , !
TDBEdit. !
ButtonStyle. : cbsAuto, cbsEllipsis cbsNon
cbsAuto. ;
( TDBEdit), (KOIV
TDBComboBox). PickList TColumn.
TStrings* .
,
( TDBComboBox). ]
, PickList, <
, (.
3.15). ;
DropDownRows. 7, . .
7 .

> 1

V Samsung ML-450G

1 *
ft

*.,
10900$ 'I

Samsung ML-1 21 0

203.001

Epson EPL-590QL

239.001

Canon LBM10

215001

,1

. 3.15. ButtonStyle cbsAuto


PickList ,

I

1 tump

Samsung ML-450Q

[(

Samsung ML,-1210

I ..

Epson EPL-5900L

239 JO

|_8-10

215.00

Brother 240 Mono Laser


Epson Aculeser Cl 000
_
"
Epson AcuLaser C2000

-
^_
\ [ '' * HP LaserJet 1200

||
-

203 DOt

266 00

1.3-19 00
2.156.00

I-

221 00

332.00

;.

. 3.16.
(lookup field),

(lookup field), ( ),
, PickList .
, . 3.14,
Category, (long integer).
Category CategoryName.
Category FieldName
CategoryName PickList, ,
(. . 3.16).

3. ()

139

cbsNone ButtonStyle ,
.
ButtonStyle cbsEllipsis, ,
( Ellipsis). (. . 3.17) OnEditButtonClick TDBGrid. OnEditButtonClick , ,
, , ,
( ).

>1

Samsung ML-45M

1 Samsung Mi_-1 21 0
1 Epson EPL-59GQL
1 Canon LBP-810

----- --

|*j

las.ous1^
"03.00$

239 00*
21500$

:.. -^

. 3.17. ButtonStyle cbsEllipsis,


(Ellipsis)
. , . 3,16, .
Items, Category ( Category Category). ,
Category,
, .
Category .
, ,
. ; ,
Category.
-. (File \ New \ Data Module). Name DModl,
TDataSource, . Tablel Items
MyData, Tablel Category . DataSet DataSourcel Tablel, DataSet DataSource2 2.
, 2,
Category.
Tablel Items.
(lookupfield), Category. ,
Tablel, New
Field. :
Q Name CategoryName.
U

Type String.

Q Size 25.
Q Field Type Lookup.
Q Key Fields Category.

140

Borland C++ Builder 6.

Q DatasetTable2.
G Lookup Keys CategoiyNo.
G Result FieldCategory.
Tablel
CategoryName.
Forml. ,
( Caption) - , Items.
TDBGrid, (DBGridl)
DataSource : DMod l-> DataSource 1.
Columns DBGridl,
FieldName CategoryName, Item Price.
(CategoryName) ButtonStyle
cbsEllipsis. .
. Title TColwnn. ,
. 3.16, (- Title):
Q Caption , ;
G

Alignment taCenter;

Q Font, Color clMaroon',


1_J Font, - Style, fsBold true.
' ,
,
, Category.
( File \ New \ Form) , , . Categories. TDBNavigator,
TDBGrid, ( TButton).
. DataSource
DBNavigatorl DBGridl DModl->DataSource2.
DBGridl Form2. ( Columns)
. Category, Description
Category. . ,
DBGridl Forml.
Form2 . , OnEditButtonClick DBGridl. ,
. , cbsEllipsis
. SelectedField TDBGrid.
SelectedField:

property Db::TField* SelectedField =


{read=GetSelectedField, write=SetSelectedField};

3. ()

141

SelectedField TField, . OnEditButtonClick DBGridl Form/:


void _ fastcall TForml : : DBGridlEdi tButtonClick(TObject *Sender)
{

TField* SelF;
SelF=DBGridl->SelectedField;
if (SelF)
if (SelF->FieldName=="CategoryName")
{

TForm2* Form2 = new TForm2(Application) ;


Form2->ShowModal() ;
Form2->Free() ;

SelF *, SelectedField. ,
- ( SelF
NULL). SelF , . CategoryName, Form2,
. , .
OnEditButtonClick , Form!.
( Project \ Options) Forms. (Auto-create forms)
Form2 (>). Form2
(Available forms).
Form2. , ,
, . , , Form2
.
OnCreate Form2. :
void _ fastcall TForm2 : : FormCreate(TObject *Sender)
{

AnsiString ValString;
ValString=Forml->DBGridl->SelectedFi eld- >AsSt ring;
if (! (ValString.IsEmptyO))
{

TLocateOptions SearchOptions ;
DModl->Table2->Locate("Category", ValString, SearchOptions);

OnCreate SelectedField.
ValString DBGridl,

142

Borland C++ Builder 6.

Forml. , /
Locate Table! ( Category) nepi
, Category <
ValString.
Form2 ( TButtori). <
( )
Category Items, Form
. Form2
. , Cancel.
OnClick :
void

fastcall TForm2::BOKClick(TObject *Sender)


TDataSet* GridDataSetl;
TDataSet* GridDataSet2;
GridDataSetl=Forml->DBGridl->DataSource->DataSet;
GridDataSet2=DBGridl->DataSource->DataSet;
if(GridDataSetl && GridDataSet2)

GridDataSetl->Edit();
GridDataSetl->FieldByName("Category")->Value=
GridDataSet2->FieldByName("CategoryNo")->Value;
GridDataSetl->Post() ;

Close 0;

OnCreate TDataSet*. GridDataSetl


,
Forml ( Table!), GridDataSetl
Form2 ( 2). ,
, , TDBGrid . //

.
TDataSet* , , Items, , Category
,
Category, Post. Form2
Close. Cancel
Close.
. CategoryName (). Form2 (. . 3.18). ,
Category ,
DBGridl, , , Category Items.

3. ()

. ..)
St.

- * -I-! I I ?
.1(-(1|1

-lEi
>

. ,

,
'(

Efu;
Ef;-;
/

,;:.
^

HI :HI

143

>;:fMlMf! '

_*]

, . 1

Intel, Aind VIA
DIMM. DIMM DDR RlMM ' .

- -
i

iLJ

OK " """|

Cancel

. 3.18. ,
( TDBGrid)
, TColumn,
, .
- Columns TDBGridColumns. ,
TDBGridColumns , : Items ( ) Count
( ). ,
.
DBGridl ListBoxl , .
for(int i=8; i <DBGridl->Columns->Count ;

Li stBoxl->I terns- >Add(DBGridl->Columns->I terns [i] ->FieldName) ;


TDBGridColumns - , . Add TColumn, . , - . Insert
TColumn ,
. Add, Insert
TColumn. Delete ,
, Clear
TColumn , TDBGridColumns.
TColumn .
SaveToFile. ,
Columns.
LoadFromFile: TDBGridColumns
, SaveToFile.
, TDBGrid ,
.
LoadFromStream SaveToStream.
TDBGridColumns , . RestoreDefaults
, , .

144

Borland C++ Builder 6.

. RebuildColumns
TColumn,
.


TDBGrid,
, Options (]. - (Set)', 13 TDBGridOption. ,
,
true. .
Q dgEditing . ,
dgRowSelect.
LJ dgAlwaysShowEditor ,
Enter F2, . dgAlwaysShowEditor , dgEditing dgRowSelect.
G dgTitles ,
.
Q dglndicator
, .
Q dgColumnResize ( ).
dgColLines .
dgRowLines .
dgTabs Tab ShiftTab. dgTabs , Tab
(Shift-Tab) , (
Shift-Tab ).
Q dgRowSelect ,
. ,
. dgEditing dgAlwaysShowEditor .
dgAlwaysShowSelection
, .
dgConfirmDelete , Ctrl + Delete, .
Q dgCancelOnExit
,
.
.
Q dgMultiSelect (
). , Ctrl.

3. ()

145


.
( ), (TCheckBox) .
, ,
dg ( Options).
Tag 1 13.
Caption TPanel. Bevellnner BevelOuter
bvLowered bvRaised .
TDBGrid, TTable TDataSource. DBGridl
DataSourcel, DataSourcel Table 1. Table!
Items MyData .
, - .
,
TCheckBox*. ,
IsFormCreate , true ,
. (Unit.h)
private TForml:
bool IsFormCreate;
TCheckBox* CBOpt[13] ;

. OnCreate Checked
true, ,
false .
CBOpt, TForml.
. TCheckBox*, CBOpt. ,
:

i n t j=0;
for(int i=Q; IComponentCount ; i++)
{

TCheckBox* CBox=dynamic_cast<TCheckBox*> (Components [i ] ) ;


if (CBox)
{
CBOpt [j]=CBox;

,
. :
for(int i=8; i<13; -i++) CBOpt [i] ->Checked=
DBGridl->Options.Contains((TDBGridOption) (CBOpt [i] -

146

Borland C++ Builder 6.

Tag
( 0),
TDBGridOption. , ]
TDBGridOption.
, Checked
( Contains Set true,
).
,
OnClick.
Tag, . OnClici
(, ) OnClick ?
.
Sender TCheckBox*, , ?
. , Checked . , ( TDBGridOption)
, . ,
Tag ( ),
TDBGridOption. , :
TCheckBox* TCB;

TDBGridOptions Opt=DBGridl->Options;

TCB=dynamic_cast<TCheckBox*>(Sender);
if(TCB)
{
if(TCB->Checked)
DBGridl->Options = Opt
((TDBGridOption)(TCB->Tag-l));
else
DBGridl->Options = Opt
((TDBGridOption)(TCB->Tag-l));
-}
, OnClick ,
,
Checked. ,
OnClick OnCreate .
, IsFormCreate,
private TForml. OnCreate
false, - true.
, Checked IsFormCreate
false. , OnClick:

if (! IsFormCreate) return;
.
3.3 3.4.
. 3.19.
3.3. GridOptionsDemo
//

#ifndef UnitlH
#defme UnitlH

3. ()

#include <Classes .hpp>


#include Controls .hpp>
#include <5tdCtrls.hpp>
#include <Forms.hpp>
include <DB.hpp>
#include <DBGrids .hpp>
include <DBTables.hpp>
include <ExtCtrls.hpp>
include <Grids.hpp>
// ------- ............ - ..... --------------------class TForml : public TForm
{
_ published:
// IDE-managed Components
TDBGrid DBGridl;
liable "Tablel;
TDataSource *DataSourcel;
TPanel *Panell;
TCheckBox *CBEditing;
TCheckBox *CBAlwaysShowEditor ;
TCheckBox *CBTitles;
TCheckBox *CBIndicator ;
TCheckBox *CBColumnResize;
TCheckBox *CBColumnLines;
TCheckBox *CBRowLines;
TCheckBox *CBTabs;
TCheckBox *CBRowSelect ;
TCheckBox "CBAlwaysShowSelection;
TCheckBox "CBConfirmDelete;
TCheckBox *CBCancelOnExit ;
TCheckBox "CBMultiSelect ;
void _ fastcall FormCreate(TObject *Sender) ;
void _ fastcall CBEditingClick(TObject *Sender)
private:
// User declarations
bool IsFormCreate ;
TCheckBox* CBOpt[l*] ;
public:
// User declarations
_ fastcall TForml(TComponent* Owner);
extern PACKAGE TForml *Forml;
// ---- ........ ------ ........

#endif

.4. GridOptionsDemo

include <vcl .h>


pragma hdrstop
include "Unitl.h"

147

148

Borland C++ Builder 6.


//

#pragma package(smart_ini t)
#pragma resource "*.dfm"
TForml *Forml;
//
__________________
_
_ fastcall TForml : :TForml (TComponent* Owner)
: TForm(Owner)

II
___________________________________
void _ fastcall TForml: : FormCreate(TObject *Sender)
{
int j=0;
IsFormCreate=false;
for(int i=0; iComponentCount ; i
TCheckBox* CBox=dynamic_cast<TCheckBox*> (Components [i] ) ;
if (CBox)
{
CBOpt[j]=CBox;

for(int i=0; i!3;


CBOpt[i]->Checked=
DBGridl->Options . Contains (
(TDBGridOption) (CBOpt [i] ->Tag-l) ) ;
IsFormCreate=true ;
}
II
void _ fastcall TForml: :CBEdi tingClick(TObject *Sender)
{
if ( ! IsFormCreate) return;
TCheckBox* TCB;
TDBGridOptions Opt=DBGridl->Options ;
TCB=dynamic_cast<TCheckBox*> (Sender) ;
if(TCB)
{

if (TCB->Checked) DBGridl->Options = Opt


((TDBGridOption) (TCB->Tag-l) ) ;
else DBGridl->Options = Opt
((TDBGridOption) (TCB->Tag-l) ) ;

3. ()

149

lulsi*
p Column Resize & Tabs
t^limin liriss

. Titles
P indicator

F RowLmee

IternNo
>

iU

tern.

Confirm Delete

Row Select

K? Cancel On b'xii

Always Snow Selection Mute Select


CetegoQ Descriptor!1

'

-*)

1 Samsung ML-45GO

A4. GDI. 03V 2 . 600 dpi 8 *

2 Samsung ML-1 210


3 Epson EPL-590QL

A4. GDI, 03V 8 , 600 dpi, 1 2 pp- ;


A GDI, 2(13) Mfj.6DQdpi.no 1J -

A Canon LBP-81 0

A GDI 600 dpi, ppm, It

5 Brother HL-1 240 Mono lasei

A .03Y2M6,6QQ*6DOapi.ao12pF>r

6 Epson AcuLeseiCI 000

. 18(256) . BOO dpi/2- j

'? Epson AcuLoser C2000

A . , 64(5! 2) Mb, 600 dpi/2-]

. 3.19. GridOptionsDemo , Column Lines


TDBGrid , . OnEditButtonClick,
, , Columns . OnTitleClick.
OnTitleClick
, .
:
typedef void

fastcall

closure *TDBGridClickEvent)(TColumn* Column);

OnTitleClick TColumn,
, . , Column
, .
OnTitleClick .
, ( , Windows
Commander -). ,
. .

OnTitleClick
OnTitleClick ,
. , ;
(TDBGridl), TDataSource TQuery.
, .
DataSourcel, , , Query].
DatabaseName Query 1 MyData.
, TQuery, TTable,
.
. , IndexName IndexFieldNames.

150

Borland C++ Builder 6.

, Addlndex. ,
. , Items
.
, 9 ( !
: , ;
). ,
( Exclusive true). , -
. , TQuery
.
.
( Items) ( ItemNc
. }
SQL SQL Query 1
( ). ,
,
> ( ), < ( ).
,
, . (
^
.
(> < ]
(..
), , .. , ,
. . !

>.
. ;
TForml ( Unitl.h), private,
private:
AnsiString SQLString;
int Curlndex;
SQLString SQL,
Query 1. ?
Curlndex Columns.
:
OnCreate OnTitleClick DBGridl. Query!
. OnCreate Forml, .

void
{

fastcall TForml::FormCreate(TObject *Sender)

SQLString=AnsiString("select * from Items");


Curlndex=0;
Queryl->SQL->Clear();

3. ()

151

Queryl->SQL->Add(SQLString + " ; " ) ;


Queryl->Acti ve=true;
TColumnTitle* Ttl=DBGr idl->Columns->I terns [0] ->Title;
Ansi String TtlCaption=Ttl->Caption;
Ttl->Caption="> " + TtlCaption;

}
SQLString Curlndex.
SQLString ,
Items. ,
( ItemNo) .
( SQL .)
Curlndex 0. ,
, .. ItemNo.
SQL Query 1.
TString, .
Clear SQL, Add SQL ;.
SQL. Query 1 .
OnCreate
(, ). ItemNo, > ( ),
Caption . , >,
.

, , . OnTitleClick.
.

void _ fastcall TForml: :DBGridlTi tleClick(TColumn Column)


{
char fc=*(Column->Title->Caption.c_str()) ;
Ansi String ColField=Column->FieldName;
int ind=Column->Index;
AnsiString OrderByString;
AnsiString CString;
i f ( f c ==

OrderByString=" ORDER BY " + ColField + " DESC;


CString=AnsiString(" ") + ColField;
else
OrderByString=" ORDER BY " + ColField +
CString=AnsiString("> ") + ColField;

}
Query l->Active=f alse;
Queryl->SQL->Clear() ;
Queryl->SQL->Add(SQLString + OrderByString);

152

Borland C++ Builder 6.

Queryl->Active=true;
DBGridl->Columns->Items[ind]->Title->Caption = CString;
if(Cur!ndex != ind)
{
TColumn* Col=DBGridl->Columns->Items[Curlndex];
Col->Ti tle->Caption=Col->DisplayName;
Curlndex=ind;
}
Queryl->First() ;
DBGridl->SelectedIndex=ind;
}

. fc char
Column, OnTitleClick. )
ColField AnsiString , !^
Column, ind Column Columns. , , ,
QueryI .
Column .
Column ,
(access violation).
AnsiString.
OrderByString SQL, .
CString ,
( > < ).
^/2; ( ).
fc >,
.
< ( < ).
, . , OnTitleClick,
.
, fc OrderByString CString. OrderByString
SQL, .
ORDER BY ( SQL ). ORDER BY ,
ColField, .
DESC, ,
. ColField
CString, , .
SQL Query]. ,
.
SQL, Query! . Column -

3. ()

153

TColumn, Columns ind.


ftemNo Kern

JGa;sgorvJDescnpnon

0 28 LR-NI. 1 024x763 (61 H:),


0.28 LR-

5" Samsung 15-

LR-NI. Pivot Block TFT LCD:'

5"Samsungl51BM

Pivot LR-NI. TFT LCD

218 5" Samsung 1 51 S.297


11 5" Samsung 550B
90 5"SamsungS51S
169
221

Pivot TFT LCD


;0.24LR-Ni, 1280:1024(60) - '
0.24 LR-NI. 1 024x768 (68 ),

6" Sarntton 6

LR-NI. 1024x768 (60 ). MPF


:

5" Sony SDM-N50 LCD


7" (16'T Samsung 753DFX,

-',

-!

4200 rpm, UDMA 100, 2.5" (^

"3" (1 1 6") LG StudioWorks 563N

185 5" (1 3.8") LG SUidioWorks 575E


', '

'

^^1|||||~

7" (16'T Samsung 753S

-0297 LR-NI. TFT LCD *.. . ,


;

0.2C LR-NI. OSD digital cortrc


7 0 23 LR-NI. OSD digital conirc ^ j

iU

Jj

. 3.20. Item
. ,
. ind Curlndex.
,
.
. . 3.20 ,
Item .


OnDrawColumnCell
TDBGrid OnDrawColumnCell,
( )
. OnDrawColumnCell , . ,
, , . ,
,
, .
:
typedef void
fastcall ( closure *TDrawColumnCellEvent)
(System::TObject* Sender, const Types::TRect &Rect, int DataCol,
TColumn* Column, Grids::TGridDraw5tate State);
Sender, ,
TDBGrid, . Sender ,
TDBGrid:
TDBGrid* grid=dynamic_cast<TDBGrid*>(Sender);
Rect TRect - , , . , ,
.

154

Borland C++ Builder 6.

DataCol ,
, Columns. ,
Index
Column TColumn*. Column o6i
-, .
OnDrawCoIumnCell, State -
TGridDrawState
. !
Q gdSelected . ,
-.
G gdFocused . <
- .
U gdFixed .

TDBGrid - OnDrawDataCe//. , State Columns csDefault


OnDrawCoIumnCell. , . .
OnDrawCoIumnCell
, Items,
( ). .
(TDBGrid),
TTable TDataSource. . Tablel ( DataSourcel), Tablel Items
MyData .
OnDrawCoIumnCell :
void

fastcall TForml::DBGridlDrawColumnCell(TObject *Sender,


const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
static TColor ColCol=clSkyBlue;
if(DataCol == 0)

if(ColCol == clSkyBlue) ColCol=clMoneyGreen;


else ColCol=clSkyBlue;

}
DBGridl->Canvas->Brush->Color=ColCol;
DBGridl->Canvas->FillRect(Rect);
DBGridl->DefaultDrawColumnCell(Rect,DataCol,Column,State);

}
//, TColor. ColCol ,

3. ()

155

.
clSkyBlue.
,
. DataCol: 0, ,
.
clSkyBlue clMoneyGreen ( ). (
, .)
, .
Rect (
, ). FillRect
. OnDrawColumnCell
DefaultDrawColumnCell, . , OnDrawColumnCell,
.


DefaultDrawing. true ( ),

OnDrawColumnCell. ,
. OnDrawColumnCell DefaultDrawColumnCell. DefaultDrawing
false,
OnDrawColumnCell (, DefaultDrawColumnCell).
.
. 3.21.
Vw^nivjIJ^t'ipUii,-

MGBI.U <'?s,ir, n
2 Samsung MH21Q

At 001. , 600 dpi.

GPL 600 dpi 8 ppm.


AiG3V2M6.68CxS3Cdpi.fi03

. 3.21. TDBGrid ()

|l

ri

Vj }1" ji > " | ~'

1 . GDI , dpi, s p
1 4, GQI,' SM&, 650 dpi, !
1 4. GDI. 2(13) . dpi,
1 -1. GUI. 1 dpi. '", nini..

< .

. 3.22. ,
,
, , ,

156

Borland C++ Builder 6.

(. . 3.22). , !
, .
. ,
, ,
.
, ,
. RecNo . (
.
OnDrawColumnCell.
void

fastcall TForml::DBGridlDrawColumnCell(TObject *Sender,


const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
int ind=Tablel->RecNo & 1;
DBGridl->Canvas->Brush->Color=ColColfind];
DBGridl->Canvas->FillRect(Rect);
DBGridl->DefaultDrawColumnCell(Rect,DataCol,Column,State);

ColCol TColor;
:
TColor ColCol []={ clSkyBlue, clMoneyGreen };
(&) () .
ind 0, 1. ColCol. , .
. , (. . 3.23).

1 4, GDI, 2 . SOU dpi, 0 ppm. 16fj , LPT.


I M, GDI. 8, <ipi o4?fipm. 1 . LPl,li-;f
1 GDI 2(13) , 600 dpt 12 , 150 (650) .
I A4.GD! eOfldpi aofippm, * LFT/!JSP -.'
1 ~..M, 56SOxCO dpi, no 12 ppm, 2SO LPT/USB
1 M user fJJJ Ifip^fiJ Ktfi, 6P,i .ir,:;:X[f>) -1p, , Jl0 C

,,-.

.,

. 3.23.

, RecNo .
SQL RecNo -1,
. , GetRecNo SetRecNo,
RecNo /.

OnDrawColumnCell . , (

3. ()

157

TDBGrid) ( Storage). ,
(, 5), Qty
,
(, 10), Lime (-). .
,
TDataSource, , .
2 Items MaData, a Tablel
Storage . DBGridl DataSourcel, &DataSoureel Tablel. (Fields Editor),
Tablel .
StoreltemNo, Qty Item Storage. Visible Item
/se, . Storage Items (
New field). ItemName, String 50. Lookup
definition : Item (Key Fields), Table2 (Dataset), ItemNo (Lookup
Fields) Item (Result Field). OK Tablel.
OnDrawColumnCell DBGridl :
void
{

fastcall TForml::DBGridlDrawColumnCell(TObject *Sender,


const TRect &Rect, int DataCol, TColumn *Column,
TGridDrawState State)
TColor Color;
TFontStyles Style=TFontStyles();
int Qty=Tablel->FieldByName("Qty")->Value;
Color=FDefaultColor;
if(Column->FieldName == "Qty")

if(Qty 5) Color=clRed;
if((Qty >= 5) && (Qty = 10))
Color=clLime;
if(Qty fsBold;

}
if(State.Contains(gdSelected)) Color=clWhite;
DBGridl->Canvas->Font->Color=Color;
DBGridl->Canvas->Font->5tyle=5tyle;
DBGridl->DefaultDrawColumnCell(Rect, DataCol, Column, State);

}
FDefaultColor,
private TForml :
.

private:
TColor FDefaultColor;
FDefaultColor Form! , :
FDefaultColor=DBGridl->Canvas->Font->Color;

158

Borland C++ Builder 6.

OnDrawColumnCell Color TCol


FDefaultColor. , ]
Qty, Color Style ( ]
11, ).

Color Style
DefaultDrawColumnCell, ;
,

if(State.Contains(gdSelected)) Color=clWhite;
, .
, ,
. , . . -
State gdSelected, .
. 3.24. , !
, , .
SlofetenijgemName
22 HPDeskJel656C
23 HP DeskJet 845C
HP DeskJet 920C
25 HP DeskJet 940C
26 HP DeskJet 960C
27 HPDeskJetSSOC
26 HPDeskJet990C "
29 HPPhotoSmartlllB
30 HP DeskJet 1220C
31 HPPSC500
32 HP Office Jet G55

|OV

[*]
12 .

<*
33
3

1 ijjji
54

; '
61

41

. 3.24. Qty ,
Qty
TDBGrid
. OnColumnMoved , ,
dgColumnResize. Sender . Fromlndex
Columns, Tolndex ,
.
OnColEnter OnColExit
. OnColExit,
OnColEnter. TNotijyEvent. , , ( /
) .
() .
TDBGrid, ,
OnCellClick ,
. , ,
. , . , () (
). OnCellClick

3. ()

159

Column TColumn. Column ,


, .
, . , ,
, .

TQuery
TQuery , TDataSet. TQuery
.
SQL . , , , .
TQuery
, SQL (
InterBase, DB2, Oracle, Informix, MS SQL Server, Sybase), (MS
Access, Paradox, dBASE, FoxPro) ODBC.
TQuery , . SQL, TQuery.
TQuery , :
Q , ;
Q , ,
;
, , , , ..;
Q ;
[ , ;
Q SQL, ;
G .
TQuery SQL,
SQL.

SQL
ANSI SQL92, ,
, SQL , .
, ,
. SQL

160

Borland C++ Builder 6.

(Local SQL). , ,
.
SQL SQL-92;
(Paradox, dBASE, FoxPro). ]
ANSI SQL-92, SQL ,
. ,
SQL-92, SQL, . ;
, SQL
, BDE. BDE <
SQL- API BDE. , , ,
SQL .
SQL . , ;
, .
SQL () (DML Dai
Manipulation Language), (
(DDL Data Definition Language).

SQL ,
. BDE
, , , .



SQL
/* */
SQL .


(Date), ,
. :
(/
( ), ( )
( ):
"mm/dd/yy"

"mm/dd/yyyy"
(.). ( ), (
) ( ):
"dd.mm.yy"

"dd.mm.yyyy"
. SQL
hh:mm:ss AM/PM, hh , mm , a ss . AM , -

3. ()

161

( , AM ). AM
. ,
. : 12:24:00.


TRUE FALSE SQL .
. . :
Where (Actual=FALSE) And (Reserved="True")
, :
F.

(DML)
SQL DML
(Select), (Delete), (Insert) (Update).

(Select)
.
.
Select [Distinct] _
From _
[Where _]
[Group By __]
[Having _]
[Order By __]
SQL, SQL , (Clauses).
, .
; , ' . ( SQL .)

Select
Select , . _ ,
. . , From, .
(*).
, From.
, ,
(, ), :
Items.Index. , ,
. AS: ItemNo^S Number.
, ,
Select Distinct.
6 . 319

162

Borland C++ Builder 6.

From
From .
From , . , !
Select, ,
From, .
. :

Select Item, Qty


From Items, Storage;

SQL
.
TQuery ,
, SQL .
, From,
. ANSI
, ("_"). SQL
ANSI,
>
: "Items, db". -
(, , ),
"Item Parts.db".
: "d:\Temp\Items.db". . : ":MyData:
Items, db". , SQL, : "Select".
SQL 3.2.
3.2. SQL
Active
And
At
Before
Both

Add
Any
Auto
Begin
By

All
As
Autoinc
Between
Bj^tes

Char

Character

Check

Column
Constraint
Current
Debug
Delete
Domain
Entry Point
Exit
Float
Function

Commit
Containing
Cursor
Dec
Desc
Double
Escape
External
For
Gdscode

Committed
Count
Database
Decimal
Descending
Drop
Exception
Extract
Foreign
Generator

After
Asc
Avg
Blob
Cache
Check_Point_
Length
Computed
Create
Date
Declare
Distinct
Else
Execute
File
From
Gen Id

Alter
Ascending
Base Name
Boolean
Cast
Collate
Conditional
Cstring
Day
Default
Do
End
Exists
Filter
Full
Grant

3. ()

163

Having

Hour

If

In
Input_Type
Isolation
Logfile

Group Commit
Wait Time
Int
Insert
Join
Lower

Inactive
Integer
Key
Leading

Index
Into
Long
Left

Like

Log_Buffer_Size

Manual

Max

Merge
Money
Nchar
Numeric
Or
Page Size
Plan
Protected
Read
Reserving
Right
Set
Size
Sqlcode
Sub Type
Then
To
Uncommitted
User
Varying
While

Message
Month
No
Of
Order
Page
Position
Primary
Real
Retain
Rollback
Shared
Smallint
Stability
Substring
Time
Trailing
Union
Value
View
With

Min
Names
Not
On
Outer
Pages
Post Event
Privileges
Record Version
Returning Values
Second
Shadow
Snapshot
Starting
Sum
Timestamp
Transaction
Unique
Values
Wait
Work

Minute
National
Null
Only
Output Type
Parameter
Precision
Raw Partitions
References
Returns
Segment
Schema
Some
Starts
Suspend
Timezone Hour
Trigger
Update
Varchar
When
Write

Inner
Is
Length
Level
Maximum
Segment
Module Name
Natural
Num LogJBuffers
Option
Overflow
Password
Procedure
RdbSDb Key
Reserv
Revoke
Select
Singular
Sort
Statistics
Table
Timezone Minute
Trim
Upper
Variable
Where
Year

Group

, From, (
). , : "Items.db" It. SQL
(). , ,
. ("Items.db"),
. , ,
(, ,
) .
From , (.. ) .
, From, -
. (Cartesian).
:

Select * From Items, Storage;

164

Borland C++ Builder 6.

SQL- BDE (, ,
) , , !
From. , *
Items
Storage. , Items 10 , ;
Storage 5, ,
10 5 = 50 .
From
. , ;
(
SQL
Inner Outer. Inner
,
, .
:
_! Inner Join _2
On (_!._!=_2._2)
On ,
.

And ( ), Or ( ) Not ( ).
(<, >, = . .).
,
.
:
From Items Inner Join Storage On (Storage.Item = Items.ItemNo)
From
Items Storage. :
, Item ( Storage) ItemNo (
Items) .
Outer. (
, !
, , !
.
( , NULL). :
From _! Left [Outer] Join _2
On (_1._! = _2. _2)
From _! Right [Outer] Join _2
On (_!._! = _2. _2)
From _! Full [Outer] Join _2
On (_!._! = _2. _2)
/,/?>?-(.>))
, (. .
, ), , ,
_1. , _-

3. ()

165

2, NULL. Right Outer ( ) . , ,


_2. , , Full Outer ( ) ,
,
. Outer , .

Where
Where ,
From. .
Where , , . Where
, . , ().
Having.
, Where
. :

! _ !
^
(=, >, < ..) (Between, Exists, In, Like, Is
Null, Some, Any, All). , , SQL.
SQL . And, Or Not.
.
,
. . Between
:

! [Not] Between 2 And


! , ! ,
Between true. Between ^/^.
,
Not. Between :
Birthday Between "01.01.01" And "01.06.01"
Exists Where .
:
Exists (_) .
_ .
, Exists true.
, From . . :
Select I.Item, I.Category, I.ItemNo, I.Description, I."Index", I.Price
From Items I
Where E x i s t s (Select Item FROM Storage S Where (5.Item = I.ItemNo)
And (S.Qty > 0))

166

Borland C++ Builder 6.

Item
,
Storage 0 (.. MI
).
In ,
:

[Not] In (_)
,
. :
( ).
, ,
In, true (false,
Not). In.

// ,
// , In
Select EmployeeNo, LName, FName, MName, Birthday
From Employee
Where (LName In ("", "", ""))
// 11 ,
// 10
Select Items.ItemNo, Category.CategoryNo, Items.Item,
Category.Category, Items.Price
From Items Inner Join Category On
(Category.CategoryNo = Items.Category)
Where (Items.ItemNo In (Select Item From Storage Where Qty <= 10))
Like true. Like.

[Not] Like [Escape ""]


,
. : LName
Like " ". Like , . . %
, , .
% . ,
Item Like "%Epson%Color%"
true , Epson
Color.
(_)
. ,
, . , b_t ( but, boot.
, Escape. escape-.

3. ()

167

% _, ,
. ,
Items, Description 50%.

Description Like "%50%%" Escape ""


Is [Not] Null , . (NULL),
( NULL).
0 ( ) NULL.
, , Any, All Some . ( Any)
:

_._ > Any ( )


,
, .
_. > (<, <=, ..).
Some Any . , true,
_
.
_ .
Any.

// Employee ,
//
//

Select El.EmployeeNo, El.LName, El.FName, El.MName, El.HireDate


From Employee El
Where El.HireDate All
(Select E2.HireDate From Employee E2
Where (EZ.FireDate Is Null) And (E2.EmployeeNo <> El.EmployeeNo))
// Employee ,
//
Select El.EmployeeNo, El.LName, El.FName, El.MName, El.HireDate
From Employee El
Where Not (El.HireDate Any
(Select E2.HireDate From Employee E2
Where (E2.FireDate Is Null) And (E2 .EmployeeNo <> El.EmployeeNo)))

,
, , .
, Where Having .
, Where . SQL,
, .

168

Borland C++ Builder 6.

// Items Category,
// Inner Join
Select Items.Item, Category.Category, Items.Description, Items.Pric
From Category Inner Join Items On (Category.CategoryNo = Items.Category)
// Items Category,
// Where
Select Items.Item, Category.Category, Items.Description, Items.Pric
From Category, Items
Where Items.Category=Category.CategoryNo

Group By
Group By
. Group By
, . , Group )
Select. ,
, . ,
Select, ( '
SQL :
Q Avg
, ,
.
Q Count , ;
.
Max, Min (
) , , .
Q Sum , , .
SQL-,
Group By.
Select Category .Category, Sum(Storage.Qty*Items.Price) As Cost
From Category Inner Join Items
On (Category.CategoryNo = Items.Category)
Inner Join Storage On (Items.ItemNo = Storage.Item)
Group By Category.Category
SQL , .
Items, Storage Category. Category . ,
Cost (), Qty ()
Price () , .

Having
Having , , , . Having Group By.

3. ()

169

Having Where. ,
Where , a Having
.

Order By
Order By , . Group By. Order By
, .
Asc,
. Desc, , . , .
, Order By ( ),
Select.
Order By.
Select Category.Category, Sum(Storage.Qty*Items.Price) As Cost
From Category Inner Join Items On (Category.CategoryNo = Items.Category)
Inner Join Storage On (Items.ItemNo = Storage.Item)
Group By Category.Category
Order By Cost Desc
, , ,
.
.

(Delete)

. , . , -
, . :
Delete From _ [Where ]
, From, , , Where. Where ,
. From Where ,
(Select).
,
( ),
, -- ,
.

(Insert)
. ,
Insert, . :

170

Borland C++ Builder 6.

Insert Into _ [(_)] Values (_)


Insert _ ;
, , , !
. .
; ,
/, , ;
. ,
, ,
, NULL. :
.
_ . ,
,
( ).
Insert
, Value
. :

Insert Into _ (_) ___)


_ ,
. _ ,
.

(Update)
{
. Update
:

Update _
Set _ = [, _ = ...]
[Where ]
_, , Where. Where ,
. , Set.
. , , Select, .
,
5%.

Update Items
Set Itemsl.Price=Iterns1.Price*!.05
Where Category=4

(Union)
Union , , . :

3. ()

171

Select I Union [All]


Select 2 Union [All]
Select n

: , , . . ,
.
. , Union
. ,
, .

(..
- ),
. , .

, Union.
. , All
,
.


, Where ( ) Set
( ) SQL, . (:) , :

Select Item, Category, Price From Items


Where Category = :CategoryNo
SQL CategoryNo,
.
.

SQL
() () , , .
, . ,
Lower ("Borland") "borland", Upper(" Borland")
"BORLAND".
Substring . :

Substring ( From [For ])


, . ,
, , .

172

Borland C++ Builder 6.

For , ,
. , :
SubstringC'Borland C++ Builder" From 13 For 7)
"Builder". , For.
Trim /
. :
Trim([Leading|Trailing|Both] [] From )
, ,
Leading, Trailing Both.
( ), ,
, . ,
Leading. , .
, :
Trim(Leading "0" From "00099456")
"99456".
Cast .
:

Cast( As _)

.
, . ,
, , .
.

Cast(Quantity As Char(5)).
Extract (, )
Date Timestamp. :

11(_ From )
_ : Day ( ), Month ( ) Year ( ).
Date Timestamp, .
, Extract.

Select LName, FName, MName, Extract(Year From HireDate) As HireYear


From Employee

SQL
, .
: ( sql)
qbe ( qbe). (sql
qbe) . sql qbe
. SQL

( ). sql qbe
Database Desktop.

3. ()

173

(DDL)
(Data Definition Language, DDL), SQL, , .
SQL , DDL, Create
Table, Alter Table, Drop Table, Create Index Drop Index.

(Create Table)
Create Table . SQL
:
Create Table _ (_ [, _,...]
[, __])
Create Table ( , )
_. db ( Paradox) /( dBASE). ,
, ,
. .
.
:

_ _.
.
.
. Primary Key.
, .
Items:

Create Table "Items.db" (


ItemNo Autoinc,
Item Varchar (50) ,
Category Integer,
Description Varchar (100),
"Items.db" ."Index" Varchar (5),
Price Money,
Primary Key (ItemNo)
)
.
, SQL.
, Database Desktop, Items. , Autoincrement
Autoinc, Alpha Char Varchar, Long
Integer. , SQL, 3.3.
, , Index.
SQL (. 3.2),
. , ,

174

Borland C++ Builder 6.

, ( ,
Create Table). !
( , -).
3.3. , SQL


Smallint

Integer

Decimal[(s[, p])]

. s
.

Numeric[(s[, p])]

Float(s, p)

11

Character(length)
Varchar(Iength)

, 1 254 .
_ _

Date

Time

Boolean

Blob(length, type)

. Blob : 1 (Memo), 2 (Binary), 3


( Memo), 4 (OLE), 5 (
). Paradox length
0 240, dBASE 0 32 767.

Timestamp

, , .

Money

Autoinc

Bytes(length)

. length
.

Constraint. Constraint
, Primary Key. Paradox dBASE
, , . ,
Constraint -
.

, .
, , , ( ) .
, , Exists /.
,
.

3. ()

175

(Alter Table)
Alter Table .
, . :
Alter Table _ Drop _ | Add _
Alter Table Drop Add.
Drop , . Drop Alter Table . .
Add. Add , Create Table: _ _.
Alter Table Add Drop.
, Alter Table
:

Alter Table Drop Description, Add Drscription Varchar(50).


. ,
, , . .
- , .
, .
.
.
. ,
, .
Alter Table . ,
, (, ).

(Drop Table)
Drop Table :
Drop Table _.

(Create Index)
Create Index . :
Create [Unique] [Asc | Desc] Index _
On _ (_! [, _ 2 . . . ] ) .
_
. . , ,

176

Borland C++ Builder 6.

. , Paradox
. dBASE , i
.
(.. , , ),
Unique. Asc (Ascending) Desc (Descending)
.
(Asc).
Employee NameNDX
LName, FName MName:

Create Index NameNDX On Employee (LName, FName, MName).

(Drop Index)
Drop Index . :

Drop Index _._.


Paradox Primary.

SQL TQuery.
(SQL Builder)
TQuery, -
. , ( DatabaseName), SQL SQL. , , SQL, ,
, SQL.
TQuery , SQL-.
, ( ),
Active TQuery true, TQuery
, (.. ).
, SQL,
( , ,
DDL),
.
Execute TQuery, ExecSQL:

Queryl->ExecSQL();
SQL ( TString).
, SQL (String List Editor).
SQL.
SQL. ,
OnCreate :

3. ()

177

Queryl->Close() ;
Queryl->SQL->Clear() ;
Queryl->SQL->Strings[0]="Select * From Items";
Query l->SQL->Strings[l]="Whe re Category=l" ;
Queryl->0pen() ;
Items, 1 . ,
Editl Button 1,
:

Queryl->Close() ;
Queryl->SQL->Strings[l]="Where Category="
Queryl->0pen() ;

Edi tl->Text;

, Editl Button 1, , . ,
, Editl
.
, , ,
.., (SQL Builder),
TQuery.
, SQL Builder
TQuery. SQL - SQL-,
SQL Builder , . ,
SQL Builder . , SQL
( , , DDL) . SQL Builder
, SQL.
SQL Builder :
Table Database. , .
Database ,
. , Database <Local Directory>,
.
. TQuery DatabaseName,
Database.
. 3.25. SQL
Builder Items
MyData
Paradox
Items IBLocal
InterBase

ITEMJp.
tern
Category
Price

Items ITEMJp ;
Items^l .Item
ltems_1 .Category
Items 1 .Price

178

Borland C++ Builder 6.

, Table
.
, .
. ^
, (_)
, ltems_1 (. . 3.25). !
, )
. : Remove Table Edit Tabh
Alias. ,
().

. , Database
. . 3.25
SQL Builder, Items
MyData Paradox Items IBLocal InterBase.
,
SQL Builder .
: Criteria, Selection, Grouping, Group Criteria, Sorting Joins.
.
, , (. . ). .
. .
Joins . ,
. ,
.

SELECT Items ITEMJD. ltems_1 Item, ItemsJ Category.


ltems_l .Price
FROM -Items.DB- ltems_l
INNER JOIN ":IBLocal:ITEMS" Items
ON (Items.lTEMJD = ltems_l.ltemNo)

. 3.26. SOL Query Text Entry


SQL Builder SQL
. Select, . , , ,
( ). ,
Selection.
, .
Criteria ,
Where SQL. Grouping
, ,
Group Criteria , -

3. ()

179

Having, Sorting.
SQL Builder, .
: , SQL Builder. , ,
SQL Builder, SQL TQuery.
.
Run SQL Query ( ). ,
Show SQL ( SQL ), SQL, SQL '. , SQL Query Text Entry
SQL (. . 3.26).
SQL, .

RequestLive

, TQuery, .
, ,
. ,
( TDBGrid), DataSourcel ( TDataSource).
DataSourcel (), (TQuery),
. ,
Items MyData, SQL TQuery,
MyData, :

Select * From Items;


TDBGrid ,
, .
(, , Items)
, , .
, (, DataSourcel) TQuery,
Items .
, , , . .. ( ReadOnly false
),
. TQuery . ,
DDL .
(Union) , .
(Select) .
- , SQL TQuery SQL, .
RequestLive, TQuery.
false. , ,
TQuery, , .
, ,
, RequestLive true. ,
( BDE) .

180

Borland C++ Builder 6.

.
.
DataSourcel TQuery.
, . RequestLive true, ,
. ,
, - TQuery , . CanModify . true, , . RequestLive
false, CanModify &, .
(Select)
.
Select Distinct.
G From Inner Join
Outer Join.
SQL (Sum, Max ..).
, ,
.
SQL .
Q Order By .
RequestLive true, (BDE) , .
,
, .
,
. UpdateObject.
TUpdateSQL.
TUpdateSQL , SQL: DeleteSQL,
InsertSQL ModifySQL. ,
, TQuery.
TUpdateSQL .


SQL TQuery (..
), (
Open Active,
RunSQL), .
: DataSource - Params.
DataSource TDataSource, ( TQuery).
, ,
.

3. ()

I b-r,,|,-.vN , j L'fltHorijry
3

ttemfJo jSem

! *.]
jjdjs?*
^!CeJegciyjDesmpfe |*j

59 Socket APC Poriner 91 1/1 00

3 VIA Apollo tCUsJ^

60 Socket APC Partner (Menli) 249

3 VIAKT133A.-- -.-

61 SocketAMenliM-KT133AB

3 V1AKT133A, '/..'.-I

62 .Socket AGIGA-BVTE GA-7ZXE

VIA KT133A, -;''-!

63 :Socket A GIGA-BYTE GA-7ZX Rev 5.X

jU

181

3 VlAKT133,Cr' " |

64 : Socket A ChainTech CT-7AJA2

3 V1AKT133A," ,

65iSocketAGIGA-BYTEGA-7ZMMH

3 'VIAKM133A,

68 SocketAASUSA7V133-C

3 VIAKT133A'..;|

67 Socket 370 FC-PGA/PPGA Canyon 6LEBM!

3 VtA Apollo ^jj?

. 3.27. CategoryNo ,
,
,
DataSource -.
(TDBGrid) , . 3.27 ( DBGrid2, DBGridl).
TQuery, TTable TDataSource, . DBGrid2 DataSource2, ,
, Tablel. Table 1 Category MyData. ,
CategoryNo Category Tablel.
: DBGridl DataSource 1 Query 1. Query 1
MyData, SQL :

Select * From Items Where category=:CategoryNo


CategoryNo Tablel,
. DataSource Query 1
DataSource2. , , . Query! . DBGrid2 DBGridl
Items,
(. . 3.27).

- Params TQuery. Params
. ,
ParamByName TQuery. ,
, :
Queryl->Params->Items[0]->AsInteger=3;
Queryl->ParamByName("CategoryNo")->AsInteger=3;
, .
:
Queryl->Close();
Query!->ParamByName("CategoryNo")->AsInteger=3;

182

Borland C++ Builder 6.

Queryl->Prepare();
Queryl->0pen();
Prepare , pt
. BDE
, .
, . ,
UnPrepare ,
.
, (
/ ). ,
, Prepared.


,
, DDL. Active
TQuery true ( Open), SQL
SQL-, .
RunSQL:

Queryl->RunSQL();
, ,
(.. , ).
RowsAffected. 0 ,
. , RowsAffected -1.
TQuery TDataSet.

, . TQuery
, ,
TUpdateSQL.

TUpdateSQL
, ( ),
( ).
TUpdateSQL.
, ; , ,
. ,
, ,
. ,
TUpdateSQL, . -

3. ()

, TUpdateSQL
.
, . , . , .
TUpdateSQL
Borland C++ Bulder 6. , , TQuery,

TUpdateSQL.
( , , ), (
, , , ).
.
(DBGridl), TQuery (Queryl), TDataSource (DataSourcel) TUpdateSQL (UpdateSQLl). DBGridl DataSourcel, ,
, Queryl. Queryl ()
MyData SQL :
SELECT StoreltemNo, Item, Qty, Description
FROM Storage
Active Queryl,
CachedUpdates true, .
. , . CachedUpdates /a/se, UpdateObject Queryl UpdateSQLl.
.
. Queryl , CachedUpdates true.
.
, UpdateSQLl .
, TUpdateSQL. VCL
TDBGrid (DBGridl), TDataSource (DataSourcel), TQueryl (Queryl)
TUpdateSQL (UpdateSQLl). DBGridl, DataSourcel Queryl
. DatabaseName Queryl
MyData, SQL :
SELECT CategoryNo, Category, Description
FROM Category
Category ( ).
RequestLive false.
. UpdateObject
UpdateSQLl, CachedUpdates true.
RequestLive false, ,
Queryl, .
.
, .

184

Borland C++ Builder 6.

-
TUpdateSQL. UpdateSQl
Editor UpdateSQLl (
UpdateObject Query 1). TUpdateSQL
Options. Tablt
Name ( ), Key Fields ( ) Update Fields ( )
Table Name , Queryl.
Get Table Fields BDE, Key Fields Update
Fields (. . 3.28). Key Fields
, . . ,
. . Update Fields , . ( Shift Ctrl).

: !
i

. 3.28. TUpdateSQL, Options


Opto .SOL

Category - :Cetegory.
Description * Description

,:,:;.

Can
ColegoryNo :OLD_CategcryNo

~1
. 3.29. SQL TUpdateSQL
, KeyFields, . , .
CategoryNo. Update Fields
,

3. ()

185

Category Description. Generate SQL.


SQL.
TUpdateSQL.
SQL-: DeleteSQL, InsertSQL ModifySQL. ,
. (, , ).
Generate SQL Options TUpdateSQL,
SQL. , SQL.
SQL ( BDE- )
: Modify, Insert Delete (. . 3.29). ,
SQL, .
, , . ,
, :.
. ,
( ), OLD_.
, .
SQL :

//Modify
Update Category
Set
Category = :Category,
Description = description
Where
CategoryNo = :OLD_CategoryNo
//Insert
Insert into Category
(Category, Description)
Values
(:Category, description)
//Delete
Delete from Category
Where
CategoryNo = :OLD_CategoryNo
,
TDBNavigator, DataSourcel, TButton.
Apply Updates :

Queryl->ApplyUpdates();
Queryl->CommitUpdates();
Cancel Updates
:

Queryl->CancelUpdates()

186

Borland C++ Builder 6.

() ,
.
,
Category, , RequestLive false (.. ).
Apply Updates.
, Cancel Updates. - . 3.30.

1
2
3
4
5

: ,

Intel AMD
Intel. Arnd VIA
DIMM, DIMM DDR RIMW

7 -
- -
8
Fujitsu, Samsung Wettern Digital
9 , , ...
10
, , 4
11
.
12
1|..

. 3.30. ,
TUpdateSQL.
, , ,

( ) ,
. ( SQL-92), TUpdateSQL.
TUpdateSQL - ,
. .
, , , , , .
, Items, Category Storage.
, RequestLive true. ,
, ,
.
,
TDataSource TQuery. , TUpdateSQL,
Storage ( Qty) Items ( Price).
, . DataSourcel,
DataSourcel . Query 1. Query 1, ,
MyData SQL :
SELECT Category.Category, Items.Item, Items."Index",
Items.Price, Items.ItemNo, Storage.StoreltemNo

Storage.Qty,

3. ()

187

FROM Items INNER JOIN Storage ON (Items.ItemNo = Storage.Item)


INNER JOIN Category ON (Items.Category = Category.CategoryNo)
ORDER BY Items.Item
, , , .
.
.
, Qty Pri . , Query 1.
. ItemNo
StoreltemNo , Visible false ( TUpdateSQL).
Item, Category Index ReadOnly
true . , CachedUpdates
Active true,
.
UpdateObject TUpdateSQL,
. .
TUpdateSQL Queryl
DataSet. TUpdateSQL . OnCreate
:

UpdateSQLl->DataSet=Queryl;
UpdateSQL2->DataSet=Queryl;
, , , , UpdateObject TQuery .
TUpdateSQL. , UpdateObject UpdateSQLl (UpdateSQL Editor)
Options. Table Name Items Get
Table Fields. Key Fields ItemNo, Update Fields Price.
Generate SQL SQL. Modify :
Update Items

Set

Price = :Price
Where
ItemNo = :OLD_ItemNo
SQL Insert Delete , .
, Beforelnsert BeforeDelete. :
Abort();
-

188

Borland C++ Builder 6.

Query 1.
UpdateSQL2.
UpdateObject Query 1 UpdateSQL2. cm
Table Name Storage Get Table Fields.
Key Fields StoreltemNo, Update Fields Qty. :
Generate SQL SQL. ;
( Modify) :
Update Storage

Set
Qty = :Qty
Where
StoreltemNo = :OLD_StoreItemNo
, , .
UpdateObject Query 1. ;
.

OnUpdateRecord Query 1. *
ExecSQL, Apply. , :
if(Updateind == ukModify)

UpdateSQLl->Apply(UpdateKind);
UpdateSQL2->Apply(UpdateKind);
UpdateAction=uaApplied;

>
, , . OnUpdateRecord
- UpdateAction uaApplied,
.
, , .
TDBNavigator TButton, , .
UpdatesPending , :
void

fastcall TForml::FormCloseQuery(TObject *Sender, bool &CanClose)

{
if((Queryl->CachedUpdates) && (Queryl->UpdatesPending))

{
switch(Application->MessageBox(
" ! ?",
"!", MB_YESNOCANCEL + MB_ICONQUESTION))
{
case IDYES:
{ Queryl->ApplyUpdates();

3. ()

189

Queryl->CommitUpdatesQ ;
break; }
case IDCANCEL:
{ CanClose=false; break; }
case IDNO:
{ Queryl->CancelUpdates(); break; }

. ,
(: . 3.31).

"1-1 '1 .

.!j

Gb Fujitsu MNN21

1 3.8") LG SludioWotks 563N

70101
60101

;1 3 ") LG StudraWorks 575E

60102

Semsung 1 51 E

60002

Semsurigl 61 8M

Samsung 1 51 i.297

J60001

Samsung 550E

^ 60105

Samsung 561 S

jcmtron 56E

:60103

'BOQOI

16")Senisung753DFX

61105

601 01

Sony SDM-N50 LCD


.1 5") Samsung 753S

10
56

61103

"*

l^j -;-

98.00S *^;

13.00$"- *':||

16.0DS

;. \':

9400$ ;

99

12.00$

86 '

8700$iV-:";"!

37.

^0.00$ -"-

98 :

$ ;
|

19.00$ ';
35
"" 69'""

!61,OQJ X:\*j$.

26

6400$ '^i'l

$"::";;.:

. 3.31. -,

TBatchMove
TBatchMove TComponent.
TBatchMove . :
;
;
Q ;
Q .
TBatchMove Source Destination. :
property TBDEDataSet* Source = {read=FSource, write=SetSource};
property liable* Destination = {read=FDestination, write=FDestination};
, Destination
( ), Source
TBDEDataSet (, TQuery, TStoredProc). , -

190

Borland C++ Builder 6.

, !
, .
TBatchMove Mode.
, (),
Destination. TBatchMode.
Q batAppend Source Destinaton
.
Q batAppendllpdate - (Destination).
- ,
. (Source), , (Destination).
G batCopy (Source)
(Destination). (. . ) , , .
G batDelete (Destination),
(Source). , BDE
. ,
. ., , , MS
Access, , , , SQL.
Q batUpdate (Destination)
(Source).
Mappings TBatchMove. TStrings*
( ). :
=
,
.
TBatchMove
. , TBatchMove
. .
G AbortOnKeyViol . true (
), ,
. false, , , .
, KeyViolTableName.
Q AbortOnProblem . true,
- -

3. ()

. false ,
,
ProblemTableName.
Q ChangedTableName AnsiString
Paradox, ,
, - .
Q CommitCount . , .
Q RecordCount , , .
Q KeyViolTableName ProblemTableName , , .
, .
TBatchMove , , .
: BDE
TBatchMove . , ,
. , ,
TQuery.
, TBatchMove
.
TDBGrid, TDataSource, TQuery, TTable TBatchMove.
. DBGridl DataSourcel, a DataSourcel Query I. Query 1 MyData,
SQL :
Select Items.Item, Category.Category, Storage.Qty, Items.Price,
Storage.Qty*Items.Price As Cost
From Items
Inner Join Category
On (Category.CategoryNo = Items.Category)
Inner Join Storage
On (Items.ItemNo = Storage.Item)

SQL, ,
Cost.
. , OnCalcFields :
Query!->FieIdByName("Cost")->AsCurrency =
Query!->FieldByName("Pri")->AsCurrency *
Query!->FieldByName("Qty")->AsInteger;
, Active Queryl true.
, , . .
, TableName Table! Report (
), Mode BatchMovel batCopy.

192

Borland C++ Builder 6.

-, (
TButton),
(OnClick) :

Queryl->Close();
BatchMovel->Execute();
DataSourcel->DataSet=Tablel;
Tablel->0pen();
Query 1.
, BatchMovel. ]
DataSourcel Tablel
.
.
, . , TBatchMove
(. . 3.32).

'Category |atj/V :4Bta.


|al
51
189 i. (
MMMM
tttwn
^ Samsung ML-1 210
88
203 DOS 17.8400
ItttttH
I Epson EPL4900L
239001
3.107001
I3J
^ Canon LBP-810
tttttat
0:
21 5 OOt
0001
^ Brother HL-1240 Mono Laser Wttttt
2;
26 OOt
532.001
Epson AcuLaser ClOOOw
HfffW
26; 1.349.001 35.074001
twtttt
AcuLeser C2000
98: 2,156 OOt 2ir28800t
/*
^ HP LaserJet ICOOw
30;
224001 6.72COOt
tttHftt :
; HP LaserJet 1200
24; 332001 7.966001

440001
sHPLeserJetl220
2;
080 OOt
tttttttt
I HP LaserJet 3200
86:
637.00t 61.152001
mum
IHP LaserJet 2200
86
761.001 66.968 OOt
Hew'

> HI

"j

. 3.32. TBatchMove
#


, , , MyBase.
.
. ,
. ,
. ,
.
, , , . , , ,
, xml cds,
.
.
, MyBase . , -

3. ()

, .
, , ,
. . , ,
.
MyBase BDE TClientDataSet
TBDEClientDataSet. .
C++ Builder,
TClientDataSet TBDEClientDataSet.
TClientDataSet , ProviderName TProviderName, , ,
(, ,
). Assign Local Data TClientDataSet.
TProviderName. . TClientDataSet
TDataSource . Load from MyBase table
.
, TClientDataSet
. Clear Data .
Save to MyBase Xml table, Save to MyBase Xml UTF8 table Save to binary
MyBase file .
xml,
cds.

ApplyUpdates.
BeforeApplyUpdates ( , ).
CancelUpdates.
TBDEClientDataSet DBConnection CommandText. DBConnection
TDatabase. CommandText
SQL. TBDEClientDataSet
. FileName
xml cds CommandText , .

.

BDE.
,
TQuery.
TDBGrid () .
7 . 319

194

Borland C++ Builder 6.

TQuery ]
SQL. , SQL,
SQL TQuery.
, (
TSession) ( TDatabase).
, TUpdateSQL (
), TBatchMove ( ),
( TClientDataSet TBDEDataSei).

- IBConsole
ISQL
Interbase
(Embedded) SQL
Interbase
Interbase
dbExpress,
Interbase Express ADO.
(unidirectional) dbExpress

TSQLClientDataSet
TSQLMonitor

- ( , ),
, .
, , , , . ,
, .
, .
.
Borland C++
, Interbase, Informix,
Microsoft SQL Server, DB2, MySQL Oracle, ODBC .
, ,
SQL dbExpress, IBExpress ADO (dbGo).
. , Interbase
SQL. Interbase . -,
, ,
(.. SQL). -, Interbase C++ Builder ( Enterprise Edition

196

Borland C++ Builder 6.

7 ( 5)), *
. , C++ Builder Enterprise Professions
Interbase (Interbase Desktop Edition). >
Interbase Desktop Edition, !
, .
, ..

. cef
, Interbase.
, , Interbase ( 6.5).

Interbase
Interbase Windows (system traj
.
InterBase Guardian. ,
Interbase. , InterBase Guardian
- . Interbase ,
. InterBase Guardian
,
Shutdown.
, ibguard.exe,
Bin , Interbase.
InterBase Guardian, Interbase.
ibserver.exe,
Bin , Interbase.
. , !
InterBase Guardian, , npi
.
, \
\ .
. !
InterBase Guardian.
. ,
InterBase Guardian .
, InterBase Guardian, Interbase , , .

, Interbase, InterBase. , , , , , - Borland. C++ Builder


, Interbase - . , .
Interbase ,
IBConsole.

4. -

Interbase
(IBConsole)

197

'$ IBConeole

!.,<,>,. 1/

Interbase, ,
- ,
( , Windows ISQL).
Interbase \
| Interbase.

. 4.1. IBConsole
ibconsole.exe',

Bin ,
Interbase.
, ( )
(. . 4.1). , (Connections Tree), (, , ,
..). Connection
Tree , , . ,
,, : ,
, , ..
IBConsole
InterBase Servers. . I Register Server and i
,
Server Information
.
Register...
Demote Server;
I* Local.Server
Server
Network Protocol:
Server Name: _
(InterBase
Servers).
Register
Ajias Name:
Server and Connect.
Description:
,.-:
Local Server (. . 4.2).
[

(User Name), (Password)
W Save Alias Information
. SYSDBA, masterkey.
Login Information
.
User Name: SYSDBA
,
Password:
(Login).
Cancel
Register Server and Connect

;);-^rv--. ~

Remote
Server (. . 4.3).

. 4.2.

198

Borland C++ Builder 6.

Server Name, Network Protocol Alias Name.


Server Name , , /
IP- . Network Protocol
, Windows.
TCP/IP, NetBEUI SPX. Alias Name
.
.
f Register Server and Connect
Server Information |.ocal Server

| Register Database and Connect


Server:

Bemcrte Server

Server Name:
|lB6Server

Local Setver

- Database^

Jetwork Protocol:

D:\Program Files\Common Files\Borlan

(TCP/IP

file.

Alias Name:
;B6

employee.gdb
ANas Name:
F Save Alias Information

Qescription:

(
:

P Save Alias Information

. 4..

. 4.4.

,
(, SYSDBA masterkey), .
.
, ,
(Local Server ), ,
. (Databases), (Sertiftcates) (Users). ,
Backup Server Log.
(Backup) (Restore). Server
Log Log- .
Logout Server ,
. ,
. Login Server,
Un-Register .

4. -

199

InterBase Servers, IBConsole . , IBConsole ( Login).


. ,
Databases ( Database).
( Create Database) (
Register...) , . 4.4.
Create Database , . 4.5.
J Create Database
Server: Local Server
F:le(s):
FilenamefeL
p:\Data\Test.gdb

Page 'Size
Default Character Set
SQL Dialect

listens

JTest
|
I

OK

" i '"" '

Cancel

. 4.5. Create Database



File(s) ( ),
. ( )
. ,
.
Alias (). ( Interbase).
File(s) ( , ). ,
.
. ,

200

Borland C++ Builder 6.

( ,
, SQL).
.
Register database ,
(
), , .
Disconnect Unregis
. Register (. . 4.4
Connect Connect As.
.
Interbase. ( )
, (Action),
. - , ]
.
(..
), (. . 4.6).
(Tables), (Indexes), (Views), (Domains),
(Stored Procedures), (External Functions),
(Generators), (Exceptions), Blob- (Blob Filters) (Roles). Cnncoi
,
SQL.

^Console

View Sewer {Database

RI-0 InterBase Servers


:
*

:
^ '
*
-

loots
'

B-13 Local Server


9-^P Databases
6"1B employee. gdb
; - Domains
:- 51
1- Indexes
! ( Views
; tl^i Stored Procedures
' fx External Functions
% Generators
Exceptions
Blob Filters
{
^ Roles
Backup
ffl Certificates
if) Server Log
i|5 Users

.
Name
COUNTRY
CUSTOMER
DEPARTMENT
EMPLOYEE
EMPLOYEE_PROJECT
g

.,,,.,

^
^

,.

Owner

Description

SYSDBA
SYSDBA
SYSDBA
SYSDBA
SYSDBA
SYSDBA
ITEMS
SYSDBA
JOB
SYSDBA
PROJECT
PROJ_DEPT_BUDGET SYSDBA
SALARY_HISTORY
SYSDBA
SALES
SYSDBA

<\

1 '1 1

. 4.6. employee.gdb
, , -

4. -

201

, (Metadata). SQL ( DDL),


. Extract
, View Metadata . ,
, SQL .
. 4.7 Items employee.gdb,
C++ Builder.
Metadata for ITEMS
Edit

: /* Table: ITEMS, Owner: SYSDBA V


! CREATE TABLE ITEHS

j(
ITEM_ID

INTEGER HOT HULL,

SPEC_ID_REF

INTEGER,

CURRENCY_ID_REF
ITEH

IHTEGER,

OARCHAR(IOO) ,

PRICE NUMERIC (9, 2) ,

DISCOUNT
NUMERICH, 2),
| PRIMARY KEY (ITEM_ID)

I);

I SET TERH ;

i/* Triggers only will work for SQL triggers */


i
JCREATE

TRIGGER CASCADE_ITEH FOR ITEHS

(ACTIVE BEFORE INSERT POSITION 0

.1 *

(Modified i
. 4.7. Items employee.gdb

Interbase .
SYSDBA, masterkey.
Interbase SYSDBA.
Users .
Users, Interbase
. SYSDBA Users Modify User. Password
Confirm Password. , .
Users . Add User
, Delete User
. ,
SYSDBA. , .

202

Borland C++ Builder 6.

Interbase
.
(,
), Interbase.
,
Add Certificate
Certificates. ID
.

ISQL
ISQL ( Interactive SQL) ,
Interbase, ;
. , ]
ISQL. , ISQL
SQL Interbase. ,
.
, , , ,
Borland (www.borland.com).
Interbase, ISQL. . , ,
- .
ISQL ,
Interbase. ISQL Interactive SQL Tools
. ISQL - , .
,
, ,
( SQL). , ( Execute
Query). , Connect,
.
ISQL (. 4.8). SQL.
(DDL) (DML). Execute Query (
) Execute Query ( Ctrl + ).
Prepare, , .
ISQL
SQL. Previous Query ( ) Next Query ( ) . ,
, . SQL, ISQL,

4. -
;| Interactive SQL- employee.qdb
Edit, Quety

Database

? - ?0 - 9? 1 ,

Transactions Windows

Help

203

r 10

select * from country

"jGlient dialect 1 (transaction is ACTIVE. jAutoDDLON


Ran

j Statistics)

. 4.8. ISQL

hst. Save SQL History


File. te- Load SQL
History. He / !
ISQL .
ISQL , Commit Rollback ( Transaction).
, ,
. , ,
.

ISQL, SQL.
: Data, Plan Statistics. Data (
) . Plan
, . . Prepare .
Statistics , :
, , .. .
, InterBase ISQL.
Interbase, .
Interbase SQL. .

2 04

Borland C++ Builder 6.

Interbase
Interbase, , , SQL,
. ,
: Interbase ,
, . , ,
Interbase gdb. ,
Interbase,
, Interbase.
, - , . - SQL ,
.
, ,
Interbase.

, Interbase
, Interbase, , . Interbase
. .
Blob. Binary Large Object ( ). , ,
, .
Blob, , .
Blob : 0 ( ), 1 (), 2 ( ), 3 (
), 4 (), 5 (
), 6 ( ,
, ). 2 6 , 0 1. .
( -32 678
-1). Interbase.
Blob , 64 ,
. 64- ,
Blob (Blob ID). , Blob ID
, Blob.
CHAR(n) CHARACTER(n). .
1 32 767 .
Q DATE. 1 100
29 32 768 . 32 .
Q 1(, ). .
(
), . , DECIMAL(5,2) ddd.dd.

4. -

205

, . , ,
. 1 18,
0 18. ,
.
16, 32 64
. ,
, Interbase.
DOUBLE PRECISION. ( IEEE),
15 . ( ): 2.225 10-38
1.797 10308. 64 .
Q FLOAT. ( IEEE), 7 . ( ): 1.175 -38 3.402 3^. 32 .
Q INTEGER. , 32 ( ).
: -2 147 483 648 2 147 483 647.
G NUMERIC (, ). DECIMAL, , ,
.
Q SMALLINT. , 16 .
: -32 768 32 767.
TIME. 00:00:00.0000 23:59:59.9999.
32 .
Q TIMESTAMP. , , . 64 .
DATE TIME, .
Q VARCHAR(n), CHAR VARYING(n), CHARACTER VARYING(n). . ,
. 1 32 765.

SQL
Interbase SQL, , , , SQL.
SQL, Interbase, SQL.
( ) .
: Interbase SQL ( SQL,
) (1, 2 3). SQL
(Embedded SQL) SQL,
. SQL (Dynamic SQL,
DSQL) . DSQL
Interbase, . SQL , 1SQL.
SQL, SQL.

206

Borland C++ Builder 6.

, 1
SQL, Interbase 5.6 . 3
SQL-92 . 2
: ,
, 3. .
3, . :
Interbase.
SQL
.
, .
(|). ,
- , (<>).
.


, SQL
, . :
CREATE {DATABASE | SCHEMA} ''
[USER '' [PASSWORD '']]
[PAGE_SIZE [=] ]
[LENGTH [=] [PAGE[S]]]
[DEFAULT CHARACTER SET ]
[<>];
DATABASE,
SCHEMA. .
,
.
.
. <>.
USER PASSWORD , , .
, . 8
. :

CREATE DATABASE 'D:\Data\MyData.gdb' USER 'SYSDBA' PASSWORD 'masterkey';


PAGEJSIZE
. .
, .
. , ,
, . , ,
,
. / -

4. -

207

, .
, .
: 1 024,2 048,4 096 8 192 . PAGEJSIZE , 4 096
. ,
Backup,
Restore. Restore .
8 192 :
CREATE DATABASE 'D:\Data\MyData.gdb'
USER ' S Y S D B A ' PASSWORD ' m a s t e r k e y '
PAGE_SIZE 8192
LENGTH.
, . , . , .
, .
.
:
<> = FILE ''
[<>]
[<>],

<> = [LENGTH [=]


{[PAGEfS]] | STARTING [AT [PAGE]] }
.
, .
, , .
( PAGEfSJ), ,
( STARTING
[AT[PAGE]]). .

CREATE DATABASE 'C:\Data\MyData.gdb'


USER 'SYSDBA' PASSWORD 'masterkey'
LENGTH 25000
FILE 'D:\Data\MyDatal.gdb'
FILE 'E:\Data\MyData2.gdb' STARTING AT 25001 LENGTH 25000 PAGES
FILE 'F:\Data\MyData3.gdb'
MyData.gdb 25 000 MyDatal D. 25 001 MyData2,
. 25 000 . Interbase
>,
F. (,
, 2
Windows 4 ).

208

Borland C++ Builder 6.

, ,
. Interbase , .
, SQI
, DEFAULT CHARACTER SET .
. Oi
, CHAR, VARCHAb
BLOB ( text), a >
.
Data Definition Guide, 13.
, , DEFAULT
CHARACTER SET NONE.

ALTER DATABASE:
ALTER {DATABASE | SCHEMA}
ADD <>;

<> ;
, CREATE
DATABASE. ALTER DATABASE .
, , SYSDBA
, . SQL ( ) :
' MyData.gdb
CREATE DATABASE 'D:\Data\MyData.gdb'
USER 'SYSDBA' PASSWORD 'masterkey';
'
ALTER DATABASE
ADD FILE 'E:\Data\MyDatal.gdb' STARTING AT PAGE 25001
ADD FILE 'E:\Data\MyData2.gdb' STARTING AT PAGE 25001
ALTER DATABASE . , 8 000
,
ADD FILE 'E:\Data\MyDatal.gdb' STARTING AT PAGE 5001
, , 8 001 ( 5 001).
, ( Backup), ( Restore),
.
. -, (Shadow). ,
. , , . (,
)
. CREATE SHADOW.

( DROP SHADOW).
Interbase.

4. -

209

DROP DATABASE. ,
, ISQL.
.

(Domains)
,
, . (Domain)
, .
typedef C/C++.
, .
CREATE DOMAIN.
:
CREATE DOMAIN [AS] <>
[DEFAULT { | NULL | USER}]
[NOT NULL]
[CHECK (<>)]
[COLLATE ];
.
.
(CHAR, VARCHAR, BLOB),
( CHARACTER SET). .
' VARCHAR 15 ; - WIN1251
CREATE DOMAIN FIRSTNAME AS VARCHAR(IS)
CHARACTER SET WIN1251;
' VARCHAR 20
' 1 3
CREATE DOMAIN EMPLOYEE AS VARCHAR(20)[1:3];
' BLOB, TEXT; - 120
CREATE DOMAIN DESCRIPTION AS BLOB SUB_TYPE TEXT
SEGMENT SIZE 120;
DEFA ULT , , . , NULL USER.
USER, . .
NOT NULL, , , . DEFAULT, NULL.
CHECK , . <> ,
:

210

Borland C++ Builder 6.


<> =

VALUE <> <>


| VALUE [NOT] BETWEEN <> AND <>
| VALUE [NOT] LIKE <> [ESCAPE <>]
| VALUE [NOT] IN (<> [, <> ...])
| VALUE IS [NOT] NULL

|
|
|
|
|
|

VALUE [NOT] CONTAINING <>.USING CREATE DOMAIN


VALUE [NOT] STARTING [WITH] <>
(<>)
NOT <>
<> OR <>
<> AND <>,

<> = {= | < | > | <= | >= | ! < | ! > | <> | !=}


<>,
. ,
. CHECK , ,
CHECK. DEFAULT
CHECK.

', ,
' 1 12
' - ()
CREATE DOMAIN MONTHNO AS SMALLINT
DEFAULT 1
CHECK(VALUE BETWEEN 1 AND 12);

' , 8
CREATE DOMAIN PHONE AS VARCHAR(IS)
CHECK(VALUE STARTING WITH '8');
'
CREATE DOMAIN ITEMNO AS INTEGER
NOT NULL
CHECK(VALUE > 0);

ALTER DOMAIN:

ALTER DOMAIN { | } {
[SET DEFAULT { | NULL | USER}]
| [DROP DEFAULT]
| [ADD [CONSTRAINT] CHECK (<>)]
| [DROP CONSTRAINT]
| TYPE
};
, CREATE DOMAIN.
ALTER DOMAIN
, , CHECK , .
DROP DOMAIN:

4. -

211

DROP DOMAIN


, ,
.
CREATE TABLE:
CREATE TABLE [EXTERNAL [FILE] '']
(<> [, <> | <0> . . . ] ) ;
. , .
:
<> = { |
COMPUTED [BY] (<>) | }
[DEFAULT { | NULL | USER}]
[NOT NULL] [<>]
[COLLATE ]
. , . ,
, ( ) ,
, . DEFAULT , COLLATE,
, , NOT
NULL, . , . ,
NOT NULL, , .
, . . , .
CHECK VALUE ( VALUE ). AS ( ). , .
COMPUTED [BY] ( BY , ).
, .
, Interbase
, .
.
, - .
, CREATE TABLE .
.
' ,
CREATE DOMAIN EmpNo AS INTEGER CHECK(VALUE > 0) NOT NULL;
CREATE DOMAIN FirstName AS VARCHAR(IS) ;

212

Borland C++ Builder 6.


CREATE DOMAIN LastName AS VARCHAR(25) NOT N U L L ;
CREATE DOMAIN MiddleName AS VARCHAR(20);
' Employee 4
' .
' Name
', .
' Now .
CREATE TABLE Employee

EmpNo
LastName
FirstName
MiddleName
Name
Birthday
HireDate
FireDate

EmpNo,
LastName,
FirstName,
MiddleName,
COMPUTED BY (FirstName || ' ' || LastName),
DATE NOT NULL,
DATE DEFAULT 'Now' NOT NULL,
DATE

);
'
CREATE DOMAIN Price AS NUMERIC(8, 2)
DEFAULT 0;
CREATE DOMAIN Qty AS SMALLINT
DEFAULT 0;
' Storage .
' , .
CREATE TABLE Storage
(

);

StoreNo
Item
Qty
Price
Cost

INTEGER NOT NULL,


INTEGER NOT NULL,
Qty,
Price,
COMPUTED BY (Qty*Price)

<> ,
, . , ,
, ,
, . , .
<> :
<0>=[CONSTRAINT ]
(UNIQUE | PRIMARY KEY}
CONSTRAINT . CONSTRAINT , Interbase
, INTEG_10.
RDBSRELATION CONSTRAINTS.

4. -

213

, UNIQUE, PRIMARY KEY.


, .. ,
, . PRIMARY KEY ,
. , , .
<>
CREATE TABLE.
, , , . :
<0> = [CONSTRAINT ] <0>
[<0> . . . ]
<0> = {PRIMARY KEY | UNIQUE} ( [, ...])
| FOREIGN KEY ( [, ...])
REFERENCES [( [, ...])]
[ON DELETE {NO ACTION[CASCADE|SET DEFAULT]SET NULL}]
[ON UPDATE {NO ACTION[CASCADE|SET DEFAULT]SET NULL}]
| CHECK (<>)
CONSTRAINT , ,
- .
, :
Q PRIMARY (1, ... , . , ,
.
G UNIQUE(nonel, ... , noneN). , , .
FOREIGN KEY (!, ... , noneN) REFERENCES [(nonel, ... , noneN)].
. ,
FOREIGN KEY, . ,
REFERENCES.
.
, .
, .
,
, (ON UPDATE) (ON DELETE).
:
Q (NO ACTION);
Q ON UPDATE , ,
(CASCADE);
UNDELETE , , (CASCADE);
Q , , ;
, , NULL.

214

Borland C++ Builder 6.

CASCADE !
.
CHECK ,
.
,

' PKeyField
' ,
' FKeyField -
CREATE DOMAIN PKeyField AS INTEGER
CHECK(VALUE > 0) NOT NULL;
CREATE DOMAIN FKeyField AS INTEGER
CHECK(VALUE > 0) NOT NULL;
'- Category
CREATE TABLE Category
(
CategoryNo
PKeyField,
Category
VARCHAR(25) NOT NULL,
Description VARCHAR(50),
PRIMARY KEY (CategoryNo),

UNIQUE (Category)

);

' Items Category ,


'
'CategoryNo Category
CREATE TABLE Items
(
ItemNo
PKeyField PRIMARY KEY,
Item

VARCHAR(50) NOT NULL,

Category
FKeyField,
Description VARCHAR(100),
Itemlndex
VARCHAR(S) NOT NULL,
Price

CONSTRAINT

NUMERIC(8,2) NOT NULL,

ItemsToCategory

FOREIGN KEY(Category) REFERENCES Category(CategoryNo)


ON DELETE CASCADE
ON UPDATE CASCADE

);
, Interbase, . :

EXTERNAL FILE ''


CREATE TABLE.
,
, .. .
CHAR ( ),
,
(EOL).

4. -

215

. ,
:
CREATE TABLE MonList EXTERNAL FILE ' D : \ D a t a \ M o n L i s t . t x t '
(
Nmon
CHAR(2),
NameMon
CHAR(12),
EOL
CHAR(2)

);

MonList.txt , ( ). .
Interbase, (,
). Interbase,
() Interbase .
. ,
, .
. ,
, - .
.

.
ALTER TABLE. ,
, ,
, , . ,
, ,
. , . :
ALTER TABLE . ,
.
ALTER TABLE:
A L T E R TABLE < 0 > [, <0> . . . ] ;
<> :
Q ADD <> . , .
CJ ALTER [COLUMN] <> . <> :
<> = {
| TYPE
| POSITION }
Q DROP .

216

Borland C++ Builder 6.

G DROP CONSTRAINT .
DROP TABLE:
DROP TABLE

(), , .

DROP DATABASE, ,
, , .
.


, , ,
, , .
- . , ,
. , , ,
, .
.
,
:
G ,
;
. ;
Q ORDER BY .
, , :
;
;
Q .
Interbase 64 . ,
Interbase ( ),
, , ( UNIQUE).
CREATE INDEX.
:
CREATE [UNIQUE] [ASCfENDING] | DESCENDING] ] INDEX
ON ( [, . . . ] ) ;
, Interbase ,
.

4. -

217

, , . UNIQUE,
() . , .
ASC , DESC .
, (ASC).
ENDING. ItemNDX Items Item:
CREATE UNIQUE ASC INDEX ItemNDX ON I terns(I tern);
Items ItemNDX ( ItemNo) ( Category) .
ALTER INDEX (, !) . :
ALTER INDEX {ACTIVE | INACTIVE};
ACTIVE ,
INACTIVE . ,
, , .
, . .
:
DROP INDEX ;
, CREATE INDEX. , Interbase
, ,
DROP INDEX .

(Generators), (Triggers)
(Stored Procedures)
. ,
. Interbase
, . , , .
(Generator) , ,
(, )
.
. , , ,
, .
, .
, , , . , :

218

Borland C++ Builder 6.

SELECT MAX(Cust_No) FROM CUSTOMER;


1
. . -,
. , ,
- , .
( ). , :
, ,
. ,
, .

. ,
, .
Interbase .
CREATE GENERATOR:

CREATE GENERATOR ;

, 0.
, GEN_ID, :
6_(, ) ;
GEN_ID . ,
, , . .
GEN_ID ,
, INSERT, UPDATE DELETE. ,
Category ,
:

INSERT INTO Category (CategoryNo, Category, Description)


VALUES (GEN_ID(Category_Gen,l), '',
' , , ")
CATEGORY^
GEN (, ISQL):

CREATE GENERATOR Category_Gen;


, . ,
DROP GENERATOR .
. RDB$GENERATORS,
:

DELETE FROM RDBSGENERATORS


WHERE "RDB$GENERATOR_NAME" = 'Category_Gen';
, SQL,
ISQL, IBConsole
. .

4. -

219

SET
GENERATOR:
SET GENERATOR ;
:
CREATE GENERATOR Category_Gen;
SET GENERATOR Category_Gen TO 1000;
:

Category _Gen
1001.

31
31 64- -2 10 2 10 1.
, , , , ,
(NUMERIC DECIMAL). ,
, INTEGER.
, . (Trigger) .
, (View). ,
. . .
CREATE TRIGGER:
CREATE TRIGGER FOR { | }
[ACTIVE | INACTIVE]
{BEFORE | AFTER} {DELETE | INSERT | UPDATE}
[POSITION ]
AS <>
CREATE TRIGGER , . , ( ), , ,
. , Interbase,
BEGIN... END.
ACTIVE INACTIVE.
,
. A C T I V E . INACTIVE .
, .
: , , , ,
. , BEFORE INSERT, , ,
( ).
. ,
POSITION. .
, .

220

Borland C++ Builder 6.

POSITION 0, ; ,
POSITION 1, ..
CREATE TRIGGER SQL
(DSQL), ISQL. , , .
(), , ISQL.
SET TERM:
SET TERM

, ISQL.
. , :
SET TERM ;

AS, , BEGIN... END:


AS
BEGIN

[]

END;'

:
DECLARE VARIABLE ;
Interbase. (INSERT,
UPDATE, DELETE SELECT), SQL,
(UDF User-Defined Functions). , :
, .

(IF... THEN) (WHILE... DO FOR SELECT... DO).

EXECUTE PROCEDURE, .
, ,
WHEN, .
OLD NEW, , ,
. .
Q .
:

IF (<>) THEN < >


[ELSE <>]
SQL .
TRUE, , THEN.

4. -

221

, ELSE,
. ELSE ,
. ,
BEGIN END.
FOR SELECT... DO:
FOR

<_5!_>
DO
<>;
SELECT ,
, () INTO. SELECT,
(UNION). INTO ,

( ).

INTO. , INTO,
, SELECT.
, DO.
FOR SELECT... DO . , SELECT, , INTO.
, DO.
FOR SELECT... DO.
ItemNo, Item, Qty Notes , , . DO Qty ( )
Notes .
FOR

SELECT Storage.ITEM AS ITEMNO,


Items.ITEM, Storage.QTY, Storage.NOTES
FROM ITEMS Items
INNER JOIN STORAGE Storage
ON (Storage.ITEM = Items.ITEMNO)
INTO : ItemNo, :Item, :Qty, -.Notes
DO
BEGIN
Notes=";
IF (Qty 5) THEN Notes='Cpo4HO !';
IF ((Qty >= 5) AND (Qty 10)) THEN Notes='!';
SUSPEND;

END
:
WHILE

(<>) DO <>

, DO, ,
TRUE.

222

Borland C++ Builder 6.

EXECUTE PROCEDURE :
:
EXECUTE PROCEDURE [TRANSACTION )
[: [ [INDICATOR] : ] ]
[, : [ [INDICATOR] : ] ...]
[RETURNING_VALUES : [ [INDICATOR] :]
[, : [ [INDICATOR] : ] . . . ] ] ;
, (input)
(output) .
RETURNING VALUE:

EXECUTE PROCEDURE SalesAnalyze :SalesDate


RETURNING_VALUES :MaxSale, :MinSale, :AvgSale, TotSale;
TRANSACTION , .
, NULL . - , ,
NULL .
OLD NEW .
. :
.
( )
EXCEPTION WHEN. EXCEPTION :

EXCEPTION ,
CREATE
EXCEPTION:

CREATE EXCEPTION
WHEN. :

WHEN SQLCODE DO EXCEPTION ;



SUSPEND. SUSPEND
,
, ( FETCH).
,
.
Interbase.
.

4. -

223

' ,
'
' ,
CREATE TRIGGER Set_Category FOR Category
ACTIVE BEFORE INSERT
AS
BEGIN
NEW.CategoryNo=GEN_ID(Category_Gen,l);
END
' Invoice ( ) ,
' Invoice_Gen,
' No. CAST
'
CREATE TRIGGER SetlnvoiceNo FOR INVOICES
ACTIVE BEFORE INSERT
AS

BEGIN
NEW.Invoice='No ' || CAST(GEN_ID(Invoice_Gen,1) AS VARCHAR(G));
END

. ,
BEGIN END, .
, , , ,
. .
IBConsole, , (,
..). , , ( Properties
, Metadata).
ALTER TRIGGER.
CREATE TRIGGER.
DROP TRIGGER .
,
, (Stored Procedure). ,
, . ,
SELECT.
CREATE PROCEDURE, , , DSQL ISQL:
CREATE PROCEDURE
[( [, . . . ] ) ]
[RETURNS ( [, . . . ] ) ]
AS

<>;

224

Borland C++ Builder 6.

(input) (output) . .
RETURNS. .
, (, , ) ,
, SaleDate, !
:SaleDate.
, , ,
Interbase. :
OLD NEW. , , :
(SELECTProcedures) (Executable Procedures).
,
, .
, . SELECT.
SQL, , .
,
ISQL:
SET TERM

CREATE PROCEDURE GetStorage


RETURNS

(
ItemNo INTEGER,
Item VARCHAR(50),
Qty SMALLINT,
Notes VARCHAR(20)

)
AS
BEGIN

FOR

SELECT Storage.Item AS ItemNo, Items.Item, Storage.Qty,


Storage.Notes
FROM Items
INNER JOIN Storage
ON (Storage.Item = Items.ItemNo)
INTO :ItemNo, :Item, :Qty, :Notes

DO

BEGIN
Notes='';
IF (Qty 5) THEN Notes='Cp04HO !';
IF ((Qty >= 5) AND (Qty 10 THEN Notes='!';
SUSPEND;

'

4. -

225

END
END

SET TERM ;

SELECT,
Items Storage. ItemNo, Item, Qty Notes, RETURNS. DO Qty (
). 5, Notes '
!'. 5, 10, Notes '!'. Notes " ( ).

(TDBGrid), OnDrawColumnCell, , ,
Notes (. 3).
SUSPEND.
. ,
SUSPEND ,
. , SELECT
, ,
INTO. , , , SUSPEND.
SUSPEND
.
. SUSPEND
DO, , Notes
. SUSPEND END,
. , , SUSPEND ,
.
(Executable) - . ,
. ,
( ) - . ,
, .
SQL: , .
()
.
, .
,
.
CREATE PROCEDURE Get_Emp_Gen
RETURNS(NumCode INTEGER)

AS
BEGIN
NumCode=GEN_ID(Emp_GEN,l);
END
8 . 319

226

Borland C++ Builder .

,
. :
TQuery (BDE) TSQLQuery (dbExpress),
: TStoredProc (BDE) TSQLStoredProc (dbExpress).
BeforePost
:

GetEmpGen->ExexProc() ;
EmpNoField->AsInteger=GetEmpGen->ParamByName("NumCode") ->As Integer;
, Employee. .

CREATE PROCEDURE Add_Employee


(
LName LastName,
MName MiddleName,
FName FirstName,
HireDate DATE,
FireDate DATE,
Birthday DATE
)
AS
BEGIN
INSERT INTO Add_Employee
(EmployeeNo, LName, MName, FName, HireDate, FireDate, Birthday)
VALUES
(GEN_ID(Emp_GEN,l) , :LName, :MName, :FName, :HireDate,
:FireDate, :Birthday);
EXIT;
END
ALTER
PROCEDURE, CREATE PROCEDURE. DROP PROCEDURE .

(Views)

. . , , ,
, . Interbase ( SQL)
(View). ( )
.
. , , ,
..

4. -

227

, ( ). .
. ,
, .
. ,
. , , , .
, ,
, .
, . . ( ) , .
, ,
,
. ,
.
,
, .

. ,
(, , , ).
,
. , , , . , , .
CREATE VIEW:
CREATE VIEW
[( [, . . . ] ) ]
AS <0neparop5elect> [WITH CHECK OPTION];
, ,
OmpamopSelect. SQL . SELECT FROM,
WHERE. ORDER BY.
UNION [ALL].
, ISQL .
. , .
, SELECT. , -

228

Borland C++ Builder 6.

. , *
, SELECT.

;
, .
KOI
WITH CHECK OPTION.- , of
, ,
. , , . }
.
WITH CHECK OPTION,
- .
.

' Employee
CREATE VIEW ViewEmp ( EmployeeNo, LName, MName, FName,
HireDate, FireDate, Birthday, Description)
AS
SELECT * FROM Employee;
' StoreView
'
'
CREATE VIEW StoreView (ItemNo, Item, CategoryNo, Category,
Description, Itemlndex, Price, Qty, Cost, Notes)
AS
SELECT Items.ItemNo, Items.Item, Category.CategoryNo,
Category.Category, I terns.Description,
Items.Itemlndex, Items.Price, Storage.Qty,
Storage.Qty*I terns.Price, Storage.Notes
FROM Category
INNER JOIN Items
ON (Items.Category = Category.CategoryNo)
INNER JOIN Storage
ON (Storage.Item = Items.ItemNo);
.
, , , ,
.
, , .
,
.
, , ,
. . -, , .. -

4. -

229

. ( .)
-, .
: WITH CHECK OPTION.
Interbase ALTER VIEW,
, ( DROP VIEW
), ( CREATE VIEW).

(Exceptions)
Interbase, .
, . ,
.
, .
, . CREATE EXCEPTION:
CREATE EXCEPTION '';
78 . ALTER EXCEPTION, a
DROP EXCEPTION. ,
- , .
,
.
EXCEPTION.
:

IF () THEN EXCEPTION ;
(
WHEN... DO):
Q , ;
G , ;
Q ,
.
. WHEN... DO.
EXCEPTION ,
WHEN, :

WHEN EXCEPTION DO
BEGIN

END
,
WHEN EXCEPTION... DO.

230

Borland C++ Builder 6.

, , . ,
BEGIN... END WHEN. , ,
.
WHEN :
WHEN

{EXCEPTION | SQLCODE ^ |

GDSCODE !15 | ANY}


DO <>
WHEN SQLCODE SQL. , SQL ,
KodOuiu6mSQL. WHEN GDSCODE
Interbase. SQLCODE
GDSCODE , SQL Interbase, , . , , ,
WHEN ANY
.


, Interbase,
, . ,
, . ()
SYSDBA. (Creator) (Owner) ,
. SYSDBA ,
.

GRANT, :
GRANT {ALL [PRIVILEGES] | <>}

ON [TABLE] { | }
{<0> | <> | GROUP TpynnaUNIX};
,
:
Q SELECT ;
Q DELETE ;
Q INSERT ;
Q UPDATE [( [, ...])] ;
REFERENCES [( [, ...])]
.
, ALL.

4. -

ON [TABLE] ,
. ,
. <>
, . :
Q PROCEDURE ;

TRIGGER ;

VIEW ;
Q PUBLIC - ,
, , , (
).
, . ([USER] )
UNIX (). ,
UNIX.
WITH GRANT OPTION.
.
GRANT.
' Accountant!
' Orders,
'
GRANT ALL ON Orders TO Accountantl WITH GRANT OPTION;
' Accountant2
'Orders Client Quantity
GRANT SELECT, UPDATE(Client. Quantity) ON Orders TO Accountant2;
' AddEmp
' Employee
GRANT INSERT ON Employee TO PROCEDURE AddEmp;
GRANT .
:
GRANT EXECUTE ON PROCEDURE
TO {<0> | <>}
,
GRANT .
Interbase, (Role).
, . , , ,
( ), ,
. , BookKeeper, .
- , :

232

Borland C++ Builder 6.

CONNECT '' USER '' PASSWORD ''


ROLE '';
CREATE,
DROP:

CREATE ROLE ;
DROP ROLE ;

//
//

,
GRANT, :
GRANT <> ON [TABLE] { | }
;
/ (SELEC1
INSERT, UPDATE, DELETE, REFERENCES) ANY. (
.
:

GRANT EXECUTE ON PROCEDURE ;


(.. ), .
GRANT:
GRANT { [, ...]} (PUBLIC)
{[USER] [, [USER]
[WITH ADMIN OPTION];

...]} }

GRANT
. ,
.
PUBLIC. ( )
.
WITH ADMIN OPTION, ,
(), , , (
()).
, GRANT,
REVOKE:

REVOKE <> ON [TABLE] { | }


FROM {<0> | <> | GROUP TpynnaUNIX};
, REVOKE,
GRANT.


SQL
( , InterBase), . - ,

4. -

233

.
.



dbExpress ( C++ Builder 6);
ADOExpress IBExpress.
BDE .
dbExpress ( dll), SQL.
dbExpress
(Vendor Library). dbExpress , dbexp . : dbexpdb2.dll
( DB2), dbexpint.dll ( Interbase), dbexpora.dll ( Oracle).

. , Borland C++
Builder (Enterprise Edition)
(DB2, Informix, Interbase, MySQL, Oracle). ,
DB2 db2cli.dll, Interbase gds32.dll,
Oracle ocldll. dbExpress (LibraryName)
(VendorLib) dbxdrivers.ini.
dbExpress, -, . ,
() ( Informix).
dbExpress Linux, .. - ( CLX).
5, C++ Builder Interbase
Express (IBExpress).
Interbase. Interbase
( , , , .. IBExpress), C++ Builder
6 Interbase (
Interbase Admin): , , ,
.. Interbase Admin ,
Interbase 6 .
, ,
Interbase.
C++ Builder ADO (ActiveX Data Objects), Microsoft. ADO OLE DB, , .
C++ Builder , ADO,
ADOExpress, dbGo.
ADO ,
Microsoft Access Microsoft SQL Server (
Microsoft).

234

Borland C++ Builder 6.

dbExpress
dbExpress
TSQLConnection. ;
dbExpress (,
TSQLClientDataSet). j
SQL, TSQLConnectio
ConnectionName, DriverName, GetDriverFunc, LibraryName VendorLib. Ho npi
Edit Connection Properties
TSQLConnection. dbExpre.
Connections (. 4.9).
f;

% , dbExpress Connections: D:\Program Files\Coi

Driver Name

Connection Settings

lnterbase

Key _
.Lvalue.
Drive rName
ilnterbase
Database
: d:\data\MylBData.gdb
RpleNarne
yser_Name
sysdba
Password
masterkey
None
SeryerCriarSet
SQLDialect
3"
BlobSize
-1
CommitRetain
False
IWaitOnLocks
True
ErrqrResqurceFil6:D:\MylBData\MylBData.err
LocaleCode
iOOOp
Interbase TranslstReadCommited

Connection Name
JIBConnection

Cancel

Hep

. 4.9. dbExpress Connections,



dbExpress Connections Connection Name
, . , , , dbxdrivers.ini. dbxconnections.ini ( Common Files/Borland Shared/DBExpress). Connection
Name - ,
Connection Settings. , , .
,
, .
, Add Connection ( +).

4. -

235

New Connection (. 4.10) . ,


dbxconnections.ini
C++ Builder. Driver Name
, Connection Name
, .
New Connection
Qriver Name
jlnterbase

Connection Name
MylBConnect

OK

Cancel

htelp

. 4.10.
Add Connection dbExpress Connections Delete Connection ( ), Rename Connection
( ), Test Connection ( ) View Driver settings ( : dbExpress/ {Library
Name/Vendor Library)).
, .
ConnectionName, DriverName, GetDriverFunc, LibraryName VendorLib
TSQLConnection .
Connected true , ,
.
Params,
. Params , (Value List editor).
, .
TSQLConnection .
KeepConnection TDatabase
BDE. false, , , ( TSQLConnection). LoginPrompt false,
.
, ( Params).
LoadParamsOnConnect. true
, ( DriverName Params)
dbxconnections.ini TSQLConnection
.

236

Borland C++ Builder 6.

dbxconnections.ini (, -(
). , *
LoadParamsFromlniFile:
void _ fastcall LoadParamsFromIniFile(AnsiString AFileName = "");
AFileName ,
, dbxconnections.ini. , AFileName .
TSQLConnection , TDatabase, TSession BDE. ,
TSession, TSQLConnection , ( , ,
, ..). Get GetTableName,
GetProcedureParams, GetProcedureNames , GetlndexNames, GetFieldNames.
TSession (BDE).
GetTableName :
void _ fastcall GetTableNames(Classes: :TStrings* List,
bool SystemTables = false) ;
List .
. SystemTables true, List .
TableScope TSQLConnection.
-, : tsTable
( ), tsSysTable ( ), tsSynonym (), tsView ().
TSQLConnection , , : BeforeConnect, AfterConnect, BeforeDisconnect,
AfterDisconnect OnLogin. , BeforeConnect
, . , .
BeforeConnect, .
void _ fastcall TForml: : SQLConnectionlBeforeConnect (TObject *Sender)

{
if (SQLConnectionl->LoginPrompt == true)

SQLConnectionl->LoginPrompt = false;
SQLConnectionl->Params->Values ["User_Name"] =
Edi tUserName->Text ;
SQLConnectionl->Params->Values ["Password"] =
Edi t Pas sword ->Text;

TSQLConnection DBConnection dbExpress.

4. -

237

IBExpress
Interbase,
Interbase Express. , InterBase, .
TIBDatabase. , , Database Editor (. 4.11).
Database Component Editor
rConnection '.. <

JLJ

Browse!

atafaase:
:JD:\Data\Myibdatagdb
Database Paranv
User Name'.
SYSDBA
Password:
jmasterkey

user_name=SYSDBA
password=masterkey

SflLRole:
Character Set
JNone
*)
R Login Prompt

OK

[' I Cancel

lest

iietp

. 4.11. TIBDatabase
TIBDatabase ,
Register Server and Connect IBConsole (. . 4.3). ,
. , , , .
Settings,
, , Params. Character Set
, LoginPrompt. ,
Test, . ,
(Successful Connection).
(.. Connected
true}, TIBDatabase

238

Borland C++ Builder 6.

.
DatabaseName, !
, Params.
, TIBDatabase ,
Interbase. SQLDialect SQL
( SQL Interbase ). *
IdleTimer ,
, ,
TIBDatabase.
KeepConnection TDatabase (BDE) TSQLConnection (dbExpress).
IdleTimer , . true KeepConnection TDatabase
TSQLConnection. false KeepConnection
IdleTimer. , Interbase Express
.
TIBDatabase AllowStreamedConnected.
,
, . Connected
TIBDatabase true ,
.
, Connected true.
AllowStreamedConnected false,
Connected
true ( Open). ,
Interbase,
.
- TraceFlags ,
SQL Monitor,
C++ Builder. , ,

SQL. . 4.12 SQL Monitor , SQL
Explorer'e MylBData , ITEMS.
TraceFlags
TTraceFlag:
Q
Q

CD

tfQPrepare Prepare;
tfQExecute ExecSQL;
tfQFetch Fetch;
tfError ;

t/Stmt SQL;

G tfConnect ,
;
Q tjTransact StartTransaction, Commit Rollback;
Q (/Blob Blob;

4. -

239

U: i SQL Monitor
View

Clients

Options

Help

Ref No. Jime Stamp SQL Statement


21:36:29
SQL Data Out: INTRBASE - Column = 12, Name = RDB$EXTERNAL_FILE, Type;
106
21:36:29
SQL Data Out: INTRBASE - Column = 15, Name = RDB$DEFAULT_CLASS,
107
SQL Data Out: INTRBASE - Column = 16, Name = RDBSFLAGS, Type = fldlNTI t
108
21:36:29
SQL Stmt: INTRBASE - Fetch
109
21:36:29
SQL Vendor: INTRBASE - isc_dsqljetch
110
21:36:29
SQL Stmt: INTRBASE - EOF
21:36:29
111
SQL Stmt: INTRBASE - Reset
112
21:36:29
SQL Vendor: INTRBASE - isc_dsql_free_statement
113
21:36:29
SQL Transect: INTRBASE -XACT Commit
21:36:29
21:36:29
SQL Vendor: INTRBASE - isc_comrnit_transaction
SQL Stmt: INTRBASE - Close
21:36.29
SQLVendor: INTRBASE - isc_dsqljree_statement

. 4.12. SQL Monitor


SQL
G

tfService ;

Q tfMisc , .
TTraceFlag - TraceFlags, SQL
Monitor. TraceFlags .

TraceFlags TDatabase TSession .


.
T/BDatabase .
TIBDatabase , ,
Interbase Express. , ( TIBDatabase), ,
. Interbase
Express TIBTransaction, .
TIBTransaction
. , Transact Editor .
.
Params. ,

240

Borland C++ Builder 6.

, :
InterBase.
TIBTransaction
DefaultDatabase TIBDatabase Active true.
,
. ,
, ,
. , Interbase ( Interbase Express)
. ,
.
, (, , , ). .
Interbase.

dbGo (ADO)
dbGo dbExpress. ,
TADOConnection,
TSQLConnection. , dbGo (, TADOConnection) Microsoft Access Microsoft SQL Server,
.
TSQLConnection
Interbase.
, ,
ODBC Interbase. ODBC, .
ODBC.
Interbase ( , , ), . ,
, ODBC Interbase EasySoft,
.
ADO Edit ConnectionString
TADOConnection. , ADO
Microsoft, , . (. 4.13) , ADO. dsn (Data Source
Name) udl (Microsoft Data Link), Use Data Link File.
Browse, . udl /Common Files/System/ole db/Data Links, dsn /Common Files/
odbc/Data Sources. , ADO .
dsn udl ( ),
Use Connection String Build.
, (. 4.14).
. Interbase ( ) Microsoft OLE DB

4. -

241

Formb>ADOConnection1 ConnectionString
Source of Connection
se Data Link File

j < Use Qonnection String

Build..
OK

fctelp

Cancel

. 4.13. ADO
Provider for ODBC Drivers. ( ).

L*i

| |
:
OLE DB
_ ^'-_j._./^.^:,,_,_^ :^_
MediaCatalogDB OLE DB Provider
MediaCatalogMergedDB OLE DB Provider
MediaCatalogWebDB OLE DB Provider
Microsoft Jet 4.0 OLE DB Provider
Microsoft OLE DB Provider For Data Mining Services
Microsoft OLE DB Providerjpr Micrgsgfj Office Search
||||||;|'1)|^'||
Microsoft OLE DB Provider for OLAP Services 8.0
Microsoft OLE DB Provider for Oracle
Microsoft OLE DB Provider for SQL Server
Microsoft OLE DB Simple Provider
MSDataShape

. 4.14. OLE DB

242

Borland C++ Builder 6.

(
DSN ODBC)
.

(. 4.15). (. . 4.16)
dsn-, ,
. ODBC (. 4.17). .
dsn- ,
.

j | |
. : :
1. :
(~

^]
:
...;
;

. ..;.'

'

'

2.

:
*

"

3. :

5
HpogepnTb

. 4.15.

4. -

243

~~~

I |
(Data Sources
'

1 ,
:
.
! , ODBC,

. 4.16.
dsn-
dsn. . ODBC EasySoft
, . 4.18. , , .
Test . ,
(. . 4.16),
dsn-. . , ( EasySoft InterBase DSN Setup),
,
. ,
, . ,
. , , , Connected TADOConnection true.
, , TADOConnection, ConnectionString. , , , , , :

Provider=MSDASQL.l;Persist Security Info=False;


User ID=5YSDBA;Extended Properties="DRIVER={Easysoft IB6 ODBC};
UID=SYSDBA;DB=d:\data\MyIBData.gdb;
FILEDSN=C:\Program FilesXCommon Files\ODBC\Data SourcesXEmpl.dsn;"

244

Borland C++ Builder 6.

, i

6.01.86
1.00.01 :

Driver para Microsoft Visual FoxPro


Mi soft Access Driverf.mdb)
MicrDsoftAccess-Treiberf.mdb)
Microsoft dBase Driver f.dbf)
Microsoft dBase VFP Driver f.dbt)
Microsoft dBase-Treiber f. dbf)
Microsoft Excel Driver (*xls)
Microsoft Excel-Treiber f.xls)
Microsoft FoxPro VFP Driver P.dbfl

4.00.44
4.00.44
6.01 .
4.00.44
4.00.44
4.00.44
.01.86

<l

..

>

. 4.17. ODBC
Easysoft InterBase DSN Setup
Database:

| D .\Deta\Myl BData.gdb

User Name:

(SYSDBA

: Password;
::Role;

"

With Schema:

"

No Wait:

Dialect:

|3 jj

Pre IB6 MetaData:

Execute Proc

"

Leave Quotes:

UID Override:

Read Only:

Character Set:

Commit Select: "


Test

OK

Cancel

Help

. 4.18. ODBC

4. -

245

, ConnectionString ,
.
TADOConnection ,
. TSQLConnection, . .

dbGo (ADO) (multi-tired)


, MIDAS, TADOConnection TRDSConnect/on, ADO.
TADOConnection
Connection dbGo
(, TRDSConnection). ADO .
ConnectionString. .
, .

dbExpress
, dbExpress,
, .
(Unidirectional Datasets)
. , . , , .
,
. (, ),
- TDataSet, ,
, .
, :
Q ,
: .
Next First, .
. , , ,
.
Q , .
Edit .

(,
SQL Update).

246

Borland C++ Builder 6.

Q , ,
.
.
SQL, WHERE.
Q .
, .
U (,
TDataSource) TDBGrid ().
, ,
.
dbExpress
TSQLTable, TSQLQuery, TSQLStoredProc TSQLDataSet.

TSQLTable
TSQLTable .
, TSQLTable
TSQLConnection. TSQLConnection - , TableName
. TableScope , TableName
. , ,
Active true.
TSQLConnection TSQLTable ( ).
SQL, . , ,
SQL . , TSQLTable Category,
:

Select * From Category;


, TSQLConnection
SQL. , ,
Execute . TSQLConnection MaxStmtsPerConn
long. Connected true,
SQL.
, .
TSQLConnection .
MaxStmtsPerConn ,
TSQLConnection , . ,
? TSQLConnection.
AutoClone true ( ),
SQL ,
(.. ). -

4. -

247

. ,
, - .
, ,
, .
, AutoClone false. . ActiveStatements. SQL.
MaxStmtsPerConn,
TSQLConnection ( SQL Execute).
TSQLTable
. ( ) TDataSource DataSet TSQLTable.
TDataSource , TDBGrid (). : Operation not allowed on a
unidirectional dataset ( ).
, , .
TSQLConnection, TSQLTable TDataSource,
. SQLConnectionl, MylBData.gdb
( Interbase , MyData). SQLTablel SQLConnectionl,
TableName Category .
SQLTablel DataSet DataSourcel.
SQLTablel Category. , (TPanel) .
(TDBNavigator), DataSourcel.
, . 4.19. .
SQLTable Demo

CATEGORYNO

CATEGORY
___..

DIMM, DIMM DDR RIMM

. 4.19. , ,
,
(Prior Last)

248

Borland C++ Builder 6.

, , , . , .. , Prior Last .
TDBEdit
. TDBEdit ,
ReadOnly true.
, , TSQLTable.
( TClientDataSet),
(TDataSetProvider).
, (. . 4.19).
TDataSetProvider
TClientDataSet, . Data Access . SQLConnectionl SQLTablel
, DataSourcel ClientDataSetl ( DataSet). ,
ProviderName ClientDataSetl DataSetProviderl,
DataSet DataSetProviderl SQLTablel.
:

DataSourcel --> ClientDataSet --> DataSetProviderl -->


SQLTablel --> SQLConnectionl
(TClientDataSet TSQLTable),
Active true. , (TDBNavigator)
, .
. , ,
, , ,
.
,
,
. , , , TDataSet ( , ..). , :
,
. , ,
. dbExpress ( TSQLClientDataSef).
, TSQLTable,
TClientDataSet TDataSetProvider.
(multi-tired) . , (
)
TDataSource, TClientDataSet TDataSetProvider. TDataSetProvider (, TSQLTable), , .
TSQLConnection, , .

4. -

249

TClientDataSet TDataSetProvider,

. .
, (. . 4.19).
. , .
- VisibleButtons,
, . , , false.
nbFirst, nbPrior, nbNext nbLast. , nbPrior
nbLast .
, nbPrior nbLast.
, .
. , nbPrior nbLast ( ). BeforeAction TDBNavigator.
:
typedef void
fastcall
TNavigateBtn Button);

closure *ENavClick)(System::TObject* Sender,

Button, ,
, . , TNavigateBtn, VisibleButtons.
BeforeAction , .
, ,
. AbortQ. BeforeAction :

void
fastcall TForml::DBNavigatorlBeforeAction(TObject *Sender,
TNavigateBtn Button)
{
if((Button == nbPrior) || (Button == nbLast))
{
AbortQ;
\
}

, , .
: TDBEdit
TEdit, ECatNo (CategoryNo), ECategory (Category) EDescription
(Description). ,
TDBEdit . ReadOnly true,
.
TEdit,
TDBEdit, -

250

Borland C++ Builder 6.

. .
AfterScroll , :
void _ fastcall TForml: : SQLTablelAfterSci"oU (TDataSet *DataSet)
{

if (!SQLTablel->FieldByName("CategoryNo")->IsNull)
{
ECatNo->Text=SQLTablel->
FieldByNameC "CategoryNo") ->AsSt ring;
ECategory->Text=SQLTablel->
FieldByName( "Category ")->AsStr ing;
EDescription->Text=SQLTablel->
Fi eldByName("Descript ion") ->AsSt ring;

Category,
AfterScroll CategoryNo . , CategoryNo
, . (, ()). , .
111("\!\ ") NULL.
, , .

. ,
.
.
RecNo, Paradox,
,
- 1 . , , .
NRec. private
TForml ( Unitl.h) :
long NRec;
OnCreate
NRec .
BeforeAction ,
, :
v o i d _ fastcall TForrtil : :DBNavigatorlBeforeAction(TObject *Sender,
TNavigateBtn Button)
{

swi tch(Button)
{
case nbFirst: { NRec=l ; break;}
case n b P r i o r : { NRec-=l; break;}

4. -

251

case nbNext: { NRec+=l; break;}


case nbLast: { NRec=SQLTablel->RecordCount ; break;}

}
if ((Button == nbPrior) || (Button == nbLast))
{

try

AbortO ;
}
_ finally
{
MoveToRecQ ;

,
. NRec .
, NRec
( RecordCount). ,
nbPrior nbLast, , ( Abort), (
MoveToRec).
Abort (EAbori).
, .
_ finally,
. ,
try... _ finally, , Abort,
. BeforeAction
Abort MoveToRec, _ finally.
MoveToRec private TForml.
, NRec.
() MoveToRec:
void _ fastcall TForml: :MoveToRec(void)
{

Process=true;
SQLTablel->First();
for(long i=l; KNRec; i++) SQLTablel->Next() ;
if (NRec == SQLTablel->RecordCount) SQLTablel->Next() ;
Process=false;

}

First Next. MoveToRec
, NRec / Next. Last, Next .
Next . (
AfterScroll

252

Borland C++ Builder 6.

NULL). Next Last .


MoveToRec (boot) Process.
private TForml OnCreatt
false. MoveToRec Process true,
false. ,
Process true. .
. ,
.
. .
(TButton) : Bins Ins, BDel Del, BEdit Edit, BPost Post, BCancel Cancel (.
. 4.20).
, .

SQLTable Demo

<

Ins

Del

Edit

Post

Cancel

\ CATEGORYNQ

CATEGORY

DESCRIPTION
:

. 4.20. ,
,
BEdit, Bins BDel , . , , .
Unitl.h TForml :

enum TKindOfState { kosBrowse, kosEdit, koslnsert, kosDelete };


private TForml KindOJState
TKindOfState OnCreate
kosBrowse. , .
BEdit:

void
{

fastcall TForml::BEditClick(TObject *Sender)


ECategory->ReadOnly=false;
EDescript!on->ReadOnly=false;
ECategory->SetFocus();

4. -

253

KindOfState=kosEdit;
}
, OnClick BEdit
.
ECategory EDescription ( ,
ReadOnly ECatNo ). ECategory ( SetFocus).
KindOfState kosEdit. ,
ECategory EDescription.
(kosEdii), : , , , .
BPost BCancel.
:
void
{

fastcall TForml::BPostClick(TObject *Sender)

if((KindOfState != kosEdit) && (KindOfState != koslnsert))


return;
int Repl;
Repl=Application->MessageBox(
" ?",
"!",
MB_YESNO + MB_ICONQUESTION);
if (Repl == IDYES) PostingO;
else CancelingQ ;

}

, . .
, Posting,
Canceling. private TForml.
Posting:

void fastcall TForml::Posting(void)


{
if(KindOfState == kosBrowse) return;
switch(KindOfState)
{
case kosEdit:
{
SQLText="Update Category Set Category='" +
ECategory->Text +
"', Description='" + EDescription->Text +
"' Where CategoryNo=" + StrToInt(ECatNo->Text) + ";";
break;

254

Borland C++ Builder 6.

case koslnsert:
SQLText="INSERT INTO Category
(Category, Description) VALUES ('" +
ECategory->Text + "', '" + EDescription->Text
NRec=SQLTablel->RecordCount+l ;
break;
case kosDelete:
SQLText="Delete From Category Where CategoryNo="
ECatNo->Text + ";";
NRec-=l;
SQLConnectionl->Execute(SQLText, NULL, NULL)
ECategory->ReadOnly=true;
EDescription->ReadOnly=true;
if (KindOfState == koslnsert) MoveToRecQ;
if (KindOfState == kosDelete)
{
if (NRec > 1) MoveToRecO;
if(NRec == 0)

ECatNo->Clear() ;
ECategory->Clear() ;
EDescription->Clear() ;

KindOf State=kosBrowse;

}
Posting
SQL. ,
koslnsert, NRec 1 ,
, NRec 1 . , SQL ( , ). ,
Execute TSQLConnection.
:

int _fastcall Execute(const AnsiString SQL, TParams Params,


void *ResultSet = NULL);
, SQL,
SQL. .
, NULL. , ,
, .
, ECategory EDescription
. , ( -

4. -

255

( ) ).
(kosBrowse).
Canceling ,
(kosEdit, koslnsert kosDelete).
, ,
,
(Read Only). (
KindOfState kosBrowse).

, . , ,
. ,
BeforeScroll , . , Process.
true, ,
MoveToRec.
BeforeScroll . , . Posting,
Canceling. .
- 4.1 4.2.
.
, , .
4.1. SQLTableDemoZ
#ifndef UnitlH
#define UnitlH

#include <Classes.hpp>
^include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
^include <DB.hpp>
#include <DBCtrls.hpp>
#include <DBXpress.hpp>
#include <ExtCtrls.hpp>
#include <FMTBcd.hpp>
#include <Mask.hpp>
#include <SqlExpr.hpp>
enum TKindOfState { kosBrowse, kosEdit, koslnsert, kosDelete };
class TForml : public TForm
published:
// IDE-managed Components
TSQLTable *SQLTablel;
TSQLConnection *5QLConnectionl;
TDataSource *DataSourcel;

256

Borland C++ Builder 6.

TIntegerField *SQLTablelCATEGORYNO;
TStringField *SQLTabTelCATEGORY;
TStringField *SQLTablelDESCRIPTION;
TLabel *Labell;
TLabel *Label2;
TLabel *Label3;
TPanel *Panell;
TDBNavigator *DBNavigatorl ;
TButton *BEdit;
TPanel *Panel2;
TPanel *Panel3;
TButton *BIns;
TButton *BDel;
TButton *BPost;
TButton *BCancel;
TEdit *ECatNo;
TEdit *ECategory;
TEdit *EDescription;'
void _ fastcall SQLTablelAf terScroll(TDataSet *DataSet) ;
void _ fastcall DBNavigatorlBeforeAction(TObject *Sender,
TNavigateBtn Button);
void _ fastcall FormCreate(TObject *Sender)
void _fastcall BEdi tClick(TObject *Sender)
void _ fastcall BPostClick(TObject *Sender)
void _ fastcall SQLTablelBeforeScroll(TDataSet *DataSet) ;
void _ fastcall BInsClick(TObject *Sender);
void _fastcall BDelClick(TObject *Sender);
void _ fastcall FormClose(TObject *Sender, TCloseAction &Action);
private:
// User declarations
long NRec;
TKindOfState KindOfState;
AnsiString SQLText;
bool Process;
void _ fastcall Posting(void) ;
void _ fastcall Canceling(void) ;
void _ fastcall MoveToRec(void) ;
public:
// User declarations
_ fastcall TForml(TComponent* Owner);
extern PACKAGE TForml *Forml;
// ----- ..... - .............. #endif
4.2. SQLTableDemo2

^include <vcl.h>
#pragma hdrstop
#include "Unitl.h"
#pragma package(smart_ini t)
#pragma resource "*.dfm"

4. -
TForml *Forml;
_fastcall TForml: :TForml(TComponent* Owner)
: TForm(Owner)

void _ fastcall TForml: :SQLTablelAfterScroU(TDataSet *DataSet)


/
if(!SQLTablel->FieldByName("CategoryNo")->IsNull)
{
ECatNo->Text=SQLTablel->
FieldBy Name ("Category No") ->As String;
ECategory->Text=SQLTablel->
FieldByName("Category")->As5tring;
EDescription->Text=SQLTablel->
FieldByName("Description")->AsString;

void

fastcall TForml::DBNavigatorlBeforeAction(TObject Sender,


TNavigateBtn Button)
switch(Button)

case nbFirst: { NRec=l; break;}


case nbPrior: { NRec-=l; break;}
case nbNext: { NRec+=l; break;}
case nbLast: {
NRec=SQLTablel->RecordCount; break;}

if((Button == nbPrior) || (Button == nbLast))

try
AbortO;
finally
MoveToRecO ;

void _ fastcall TForml: :FormCreate(TObject *Sender)


{
NRec=l;
KindOfState=kosBrowse;
Process=false;

9 .319

257

258

Borland C++ Builder 6.

void _fastcall TForml::BEditClick(TObject *Sender)


ECategory->ReadOnly=false;
EDescription->ReadOnly=false;
ECategory->SetFocus();
KindOfState=kosEdit;
void _ fastcall TForml : :Posting(void)
{
if (KindOf State == kosBrowse) return;
switch(KindOfState)
{
case kosEdit:
{
SQLText="Update Category Set Category='" +
ECategory->Text +
" ' , Description^" + EDescn'ption->Text +
'" Where CategoryNo=" + StrToInt(ECatNo->Text) + ";";
break;
}

case koslnsert:
{
SQLText="INSERT INTO Category
(Category, Description) VALUES ('" +
ECategory->Text + "', '" + EDescription->Text +

"'):";

NRec=SQLTablel->0RecordCount+l;
break;

}
case kosDelete:
{
SQLText="Delete From Category Where CategoryNo=" +
ECatNo->Text + ";";
NRec-=l;

SQLConnectionl->Execute(SQLText, NULL, NULL)


ECategory->ReadOnly=true;
EDescription->ReadOnly=true;
if (KindOf State == koslnsert) MoveToRecO;
if (KindOfState == kosDelete)
{
if (NRec > 1) MoveToRecO;
if(NRec == 0)
{

ECatNo->Clear() ;
ECategory->Clear() ;
EDescription->Clear() ;

KindOf State=kosBrowse;

4. -

void ^fastcall TForml::BPostClick(TObject Sender)


{
If((KlndOfState !- kosEdit) && (KindOfState != koslnsert))
return;
int Repl;
Repl=Application->MessageBox(
" ?",
"!".
MB_YESNO + MB_ICONQUESTION);
if (Repl == IDYES) PostingO;
else CancelingO;
void

fastcall TForml::Canceling(void)
if((KindOfState != kosEdit) && (KindOfState != koslnsert))
return;
ECatNo->Text=SQLTablel->FieldByName("CategoryNo")->AsString;
ECategory->Text=SQLTablel->FieldByName("Category")->AsString;
EDescription->Text=SQLTablel->FieldByName("Description")->
AsString;
Ki ndOfState=kosBrowse;
ECategory->ReadOnly=true;
EDescription->ReadOnly=true;

void _fastcall TForml: :SQLTablelBeforeScroll(TDataSet DataSet)


{
if(Process) return;
if ((KindOfState == kosEdit) || (KindOfState == koslnsert))
{
int Repl;
Repl=Application->MessageBox(
" . ?",
" ' **
MB_YESNO + MB_ICONQUESTION) ;

if (Repl == IDYES) PostingO;


else CancelingO ;

void _fastcall TForml: :BInsClick(TObject Sender)


{
KindOfState=kosInsert;
ECatNo->Text="";
ECategory->Text="";
EDescription->Text="" ;
ECategory ->ReadOnly=false;
EDescription->ReadOnly=false;

259

260

Borland C++ Builder 6.

ECategory->SetFocus() ;
void _ fastcall TForml: :MoveToRec(void)
{
Process=true;
SQLTablel->First();
for(long i=l; KNRec;

i++) SQLTablel->Next() ;

if(NRec == SQLTablel->RecordCount) SQLTablel->Next()


Process=false;
void _ fastcall TForml: :BDelClick(TObject *Sender)
{
Ki ndOf State=kosDelete ;
int Repl;
Repl=Application->MessageBox (
" ?", "!",
MB_YESNO + MB_ICONQUESTION) ;
if (Repl == IDYES) PostingQ;
else KindOfState=kosBrowse;
void _ fastcall TForml: :FormClose(TObject Sender.
TCloseAction &Action)
{
if((KindOfState == kosEdit) || (KindOfState == koslnsert))
{
int Repl;
Repl=Application->MessageBox(
" . ?",
"! " ,
MB_YESNO + MB_ICONQUESTION);

if (Repl == IDYES) PostingO;


else CancelingO ;

4.1 4.2 ,
.
. , .
.

TSQLQuery, TSQLStoredProc TSQLDataSet


TSQLTable
, ,
TableName. , -

4. -

261

, TSQLTable .
, ,
. TSQLQuery.
TSQLQuery SQL . SQL SQL. , , true Active.
(INSERT, UPDATE, DELETE) (
(DDL)) ExecSQL. , TQuery BDE,
TSQLQuery. , ,
TSQLQuery, .
dbExpress . DBConnection TSQLStoredProc
-, StoredProcName
.
, ,
Active true. .
, (.. ), .
(input) (output) Params. StoredProcName
, Params .
,
Params. - , .
, , .
Q . ParamType: ptlnput
( ), ptOutput ( ), ptinputOutput ( , ), ptResult ( , ;
), ptUnknown ( ; -
).
Q DataType. ,
, DriverName TSQLConnection.
TSQLStoredProc ,
DataType , . , , .
Size, Precision NumericScale. ,
(
).
Q Value. .
, ,
. ,

262

Borland C++ Builder 6.

Value ,
:

StoredProcl->DBConnection="SQLConnectionl";
StoredProcl->StoredProcName="ADD_EMPLOYEE";
StoredProcl->Params->Clear()
;
StoredProcl->Params->ParamByName("LName")->AsString="HeKTO";
,
( ).
, Execute TSQLStoredProc. ,
, true Active TSQLStoredProc,
Open.
, , .
,
.
Value .
TDataSet, dbExpress, TSQLDataSet. ,
. , , .
TSQLDataSet CommandType CommandText. , , SQLConnection TSQLConnection.

-'
EMPLOYEE
INVOICES
ITEMS
MONLIST
STORAGE

CATEGORY
CATEGORYNO
DESCRIPTION

. 4.21. , CommandText
TSQLDataSet

4. -

263

CommandType ,
TSQLDataSet. , ,
: ctQuery, ctTable ctStoredProc.
ctTable, CommandText
(, , , TableScope TSQLConnection).
CommandType ctStoredProc,
CommandText . , , ctQuery, CommandText
. CommandText (. . 4.21). , ,
, , SQL
, SQL .
TSQLQuery
TDataSet
dbExpress. TSQLDataSet ,
, Active true (
Open). - ExecSQL.

TSQLCIientDataSet
TSQLClientDataset TDataSet
dbExpress, , . ,
,
. , .
. ,
, MyBase, . xml cds; xml cds.
MyBase ,
(), . TSQLCIientDataSet , .
, , xml cds. , ,
, TSQLConnection .
TSQLCIientDataSet
FileName . ,
.
Load from MyBase table TSQLCIientDataSet.
TSQLCIientDataSet TDataSource, , ,
, (TDBGrid). .

264

Borland C++ Builder 6.

, LoadFromFile, :

void

fastcall LoadFromFile(const AnsiString FileName = "");

, . ,
, ,
FileName. LoadFromFile. ,
d:\Data\Category.cds:

SQLClientOataSetl->LoadFromFile("D:\\Data\\Categ.cds");
SQLClientData5etl->Open():
LoadFromFile TCustomCachedDataSet, TSQLClientDataSet. SaveToFile,
, ,
TCustomClientDataSet, , TCustomCachedDataSet. :

void
fastcall SaveToFile(const AnsiString FileName = "",
. TDataPacketFormat Format = dfBinary);
FileName AnsiString ,
TSQLClientDataSet.
Format TDataPacketFormat ,
. : dfBinary ( cds), dJXML (xml -),
dfXMLUTFS (/- UTF8).
MyBase ,
(- ). ,
MyBase , (briefcase model).
. . ,
(, ),
. , ,
, , .

, .
,
. TDBGrid, TDataSource, TSQLClientDataSet TSQLConnection, , . SQLConnectionl
MylBData. DBGridl DataSourcel,
, , SQLClientDataSetl.
(TButton), (
Caption): BGetData , BOnOffu , BSaveData . , . 4.22.

4. -

265

I I

ITEMNITEM
[Samsung ML-4500
2i Samsung ML-1210
'^

ICATEGJCJESCRIPTION
11 AACaDI, 2, 600jdpi.jil
11A4, GDI ' . 600 dpi
|
|
|

1]41,600 dpi, 8 ppm. (**^


5 (Brother HL-1^40 Mono Laser
6 [Epson AcuLaser C1 OOOw
7 (Epson AcuLaser C2000
8 HP LaserJet 10OOw
1JHP Laser Jet 1200
LaserJet 1220

| A4, , 16(256) . ***

_^

^.^!!??0^!!,

1 i A4, 600 dpi - 24 ,

. 4.22. ,

BGetData ( ) , CommandText
SQLClientDataSetl , .
BGetData:

void _ fastcall TForml: :BGetDataClick(TObject Sender)


int repl;
if (FileExists(DataFileName))

repl=Application->MessageBox(
" . ?",
"!",
MB_YESNO + MB_ICONQUESTION);
if(repl == IDNO) return;
SQLClientDataSetl->Active=false;
SQLClientDataSetl->FileName="";
SQLClientDataSetl->DBConnection=SQLConnectionl;
SQLClientDataSetl->CommandType=ctTable;
SQLClientDataSetl->CommandText="ITEMS";
SQLClientDataSetl->Active=true;
SQLClientDataSetl->SaveToFile(DataFileName, dfBinary);
SQLClientDataSetl->Active=false;
BOnOff->Caption = "";
,

266

Borland C++ Builder 6.

DataFileName, :
Ansi String DataFileName="d: \ \ D a t a \ \ B r i e f . c d s " ;
, .
BGetData
. ,
. ,
. ,
. , SQLClientDataSet. , . :
Filename, SQLClientDataSet 1,
(ctTable) ITEMS. :
, , ,
.
SaveToFile, ,
. .
BGetData BOnOffaoy . cds, Items.
BOnOff
Items.
:

void _ fastcall TForml: :BOnOffClick(TObject Sender)


{
if (BOnOff->Caption == "")
{
SQLClientOataSetl->DBConnection=NULL;
SQLClientDataSetl->FileName=DataFileName;
SQLClientDataSetl->Active=true;
BOnOff->Caption = "";
else

SQLClientDataSetl->Act1ve=false;
BOnOff->Caption = "";
.
, .
DBConnection ( , ), FileName
. .
.
BSaveData -

4. -

267

(),
.
, .
LogChanges true ( ),
TSQLClientDataSet , (, ,
). TSQLCLientDataSet Data.
Data , . ,
, ; Delta, OleVariant.
ChangeCount.
, ,
ApplyUpdates. (
FileName DBConnection TSQLConnection),
ApplyUpdates, :

virtual int

fastcall ApplyUpdates(int MaxErrors);

ApplyUpdates MaxErrors
, . MaxErrors -1;
.
ApplyUpdates .
Q Before ApplyUpdates.
Q TSQLClientDataSet,
Delta . ,
.
Q After ApplyUpdates.
Q Reconcile. , ,
OnReconcileError. , Delta ,
. MergeChangeLog
Data,
ChangeCount.
ApplyUpdates ,
.
LogChanges false,
Data.
, . .
.
BSaveData:

void
{

fastcall TForml::BSaveDataClick(TObject *Sender)


int repl;
if(SQLClientDataSetl->ChangeCount == 0) return;

268

Borland C++ Builder 6.

if(FileExists(DataFileName))
{
repl=Application->MessageBox(
" ?",
"!",
MB_YE5NOCANCEL + MB^ICONQUESTION);

}
if(repl == IDCANCEL) return;
SQLClientDataSetl->Active=false;
BOnOff->Caption = "";
SQLClientDataSetl->DBConnection=SQLConnectionl;
SQLClientDataSetl->CommandType=ctTable;
SQLClientDataSetl->CommandText="ITEMS";
SQLClientDataSetl->Active=true;
if(repl == IDYES)
SQLClientDataSetl->ApplyUpdates(-l);
else
SQLClientDataSetl->CancelUpdates();
SQLClientDataSetl->Active=false;
}

( ChangeCouni). , .
Cancel, .
SQLConnection,
Items. ,
ApplyUpdates, CancelUpdates,
.
.

TSQLClientDataSet . , . ApplyUpdates
,
. ,
TSQLClientDataSet ,
. , ,
, .
, OnGetTableName BeforeUpdateRecord. OnGetTableName TCustomCachedDataSet :

typedef void
fastcall ( closure *TGetTableName)(TObject* Sender,
Db::TDataSet* DataSet, AnsiString &TableName);
, , . TableName. -

4. -

269

. Sender
, DataSet
.
BeforeUpdateRecord. , Delta (..
).
TCustomCachedDataSet;
typedef void
fastcall ( closure *TBeforeUpdateRecordEvent)
(TObject* Sender, TDataSet SourceDS, TCustomClientDataSet *DeltaDS,
Db::TUpdateKind UpdateKind, bool &Applied);
, OnGetTableName,
. DeltaDS
, . UpdateKind , : ukModify ( ), uklnsert ( ),
ukDelete ( ). ,
, Applied. Applied true, . Applied false.
, . ,
, Applied
true, , , false (
, ).
BeforeUpdateRecord:

void
{

fastcallTForml::SQLC1ientDataSetlBeforeUpdateRecord(TObject
*5ender, TDataSet *SourceDS, TCustomClientDataSet *DeltaDS,
TUpdateKind UpdateKind, bool &Applied)
AnsiString SQLString;
SQLConnection *Connectionl=
(dynamic_cast<TCustomSQLDataSet *>(SourceDS)->5QLConnection);
switch (UpdateKind)
case ukModify:
SQLString="Update ! " +
"Set 1=" + FormatFunc(DeltaDS->Fields->
Fields[l]->NewValue) + ","
"rioneN=" + FormatFunc(DeltaDS->Fields->
Fields[N]->NewValue) +
"Where 1=" +
FormatFunc(DeltaDS->Fields->Fields[0]->OldValue)
Connectionl->Execute(SQLString, NULL, NULL);
(
)
break;

270

Borland C++ Builder 6.


case ukDelete:
SQLString="Delete From ! " +
"Where 1=" +
FormatFunc(DeltaDS->Fields->Fields[0]->OldValue)
Connectionl->Execute(SQLString, NULL. NULL);
( )
break;

case uklnsert:
SQLString="Insert Into !(!. ... ) " +
"Values (" + FormatFunc(DeltaDS->Fields->
Fields[l]->NewValue) + ","
FormatFunc(DeUaDS->Fields->Fields[N]->NewValue) +
) - +

"Where 1=" +
FormatFunc(DeltaDS->F1elds->Fields[e]->OldValue)
Connectionl->Execute(SQLString, NULL, NULL);
(
)
break;
}
BeforeUpdateRecord FormatFunc

AnsiString (, IntToStr).
TSQLClientDataSet ,
.
,
(,
/). ,
TSQLClientDataSet,
dbExpress.

TSQLMonitor
dbExpress, ,
TSQLMonitor. , C++ Builder, TSQLMonitor .
, ,
TSQLConnection. TSQLMonitor TSQLConnection SQL,
.
TraceList,
. StringList .
TSQLMonitor . BriefcaseDemo,
, .
, -

4. -

271

. TSQLMonitor
SQLConnection SQLConnection. (He ,
dbExpress DBConnection.) ,
FileName.
,
FileName. SQL,
TSQLMonitor. ,
AutoSave true. true
Active, TSQLMonitor .
.
- , SQLConnection 1. , ,
, . .
, SQL, SQLConnection 1
(. . 4.23).

INTERBASE - isc_attach_database
INTERBASE - isc_dsql_allocate_statement
INTERBASE - isc_start_traneaction
select * from "ITEMSINTERBASE - isc_dsql_prepare
INTERBASE - isc_dsql_describe_bind
INTERBASE - isc_dsql_execute
INTERBASE - isc dsql allocate.statement
SELECT 0, ", ", A.RDB$RELATION_NAME, A.RDB$INDEX_NAME,
INTERBASE - isc_dsql_prepare
INTERBASE - isc_dsql_describe_bind
INTERBASE - isc_dsql_execute
INTERBASE - isc.dsql.fetch
INTERBASE - isc_dsql_fetch
INTERBASE - isc_dsql_fetch
INTERBASE - isc_dsql_fetch
. 4.23. TSQLMonitor
SQL
TSQLMonitor.
OnLogTrace.
:

typedef void
fastcall ( closure *TTraceLogEvent)
(System::TObject* Sender, pSQLTRACEDesc CBInfo);

272

Borland C++ Builder 6.

OnLogTrace , TraceList. Sender TSQLMonitor, . CBInfo


pSQLTRACEDesc, . :

struct SQLTRACEDesc {
char pszTrace[1024];
TRACECat eTraceCat;
int ClientData;
WORD uTotalMsgLen;
}
pszTrace , uTotalMsgLen . ClientData (callback), .
eTraceCat TSQLTraceFlag, (). :
Q traceQPREPARE .
traceQEXECUTE .
Q traceERROR . .
Q traceSTMT ALLOCATE, PREPARE,
EXECUTE FETCH.
Q traceCONNECT / , .
G traceTRANSACT , (BEGIN, COMMIT
ROLLBACK).
Q traceBLOB Binary Large Object, STORE BLOB,
GET BLOB ..
traceMISC (),
.
Q traceVENDOR API (, isc_attach_database
isc_ Interbase).
Q traceDATAIN , , , Update
Insert.
CD traceDATAOUT .
, CBInfo,
. , OnLogTrace , TraceList ,
. OnLogTrace,
TraceList ,
:

void

fastcall TForml::SQLMonitorlLogTrace(TObject *Sender,


pSQLTRACEDesc CBInfo)

4. -

{
*

273

TSQLMonitor *Monitorl = dynamic_cast<TSQLMonitor *>(Sender);


Monitori->SaveToFile("D:\\Data\\trace.txt");
Monitorl->TraceList->Clear();

TSQLMonitor.
,
TraceList. :
typedef void
fastcall ( closure *TTraceEvent)
(System::TObject* Sender, pSQLTRACEDesc CBInfo, bool &LogTrace);

,
OnLogTrace, LogTrace . true, ..
TraceList. TraceList,
LogTrace false.
TSQLMonitor , . TraceCount, , , TraceList. TraceList
( Clear) TraceCount 0. MaxTraceCount
,
TraceList.
, , , TSQLMonitor. ,
. , , . , ,
.
,
.

, - .
Interbase. , Interbase,
IBConsole ISQL. , , , , , ,
Interbase.
Interbase. ,
, Interbase,
Interbase (, , ),
.

. Interbase
dbExpress, IBExpress ADO. -

274

Borland C++ Builder 6.

, dbExpress. BHJ
, !
TSQLTable, TSQLQuery, TSQLStoredProc TSQLDataSet.
, !

.
TSQLClientDataSet TSQLMonitor.

MyBase ( )
, TSQLMonitor ,
- TSQLConnection .

''".

" '

Quick Report

TQuickRep

TQRLabel, TQRDBText, TQRExpr TQRSysData

Quick Report
Decision Cube

. (.. ) (, ..). ( )
QuickReport, ,
Decision Cube.
. QuickReport.


QuickReport
Quick Report , QuSoft AS
(www.qusoft.com) QBS Software (www.qbss.com).
C++ Builder 3.0.9, Web- 5.0 Professional.
QReport 23 .
. .
.

276

Borland C++ Builder 6.



, ,
, .
, .
, Other File \ New. New Items nepei
Business Quick Report Wizard,
(. 5.1).

Creates aiisiing style report with fields from


one table.

. 5.1.
, , .
, Select
Report. , C++ Builder,
, List Report ( ).
, Start Wizard.
( .5.2).
.
. ( A lias or directory),
Table name. Available fields.
(>, , < ), ,
.
Selected fields. , Finish. . , (. 5.3).

5.

277

rSelect atable
*[

^lias of directory JMyData


Jabiename

Browse

ltems.DB

Select Fields-:"
Bailable fields
ItemNo
Item
Category
Description
Index
Price

Fmish

Cancel

. 5.2.

StemNIo

" ]tem

Page Foote:

'

. 5.3. -
, - , . , ,

278

Borland C++ Builder 6.

, |
, . ,
TQuickRep, .
. : <
BDE. ,
BDE.
Forml
- Form2. <
, . Form2
Forml. Forml File Include Unit He
Unit2 .
Forml ( TButton).
:
Form2->QuickRepl->Preview();

Forml, . , :
Print Preview, (. 5.4).
Print Preview

iNo

Item

Category

Description

1 Samsung ML-4500

1 A4, GDI, 2 , 600 dpi. 8 ppm,

2 Samsung ML-1210

1 A4, GDI, 8 , 600 dpi, 12 ppm, Jioi

3 Epson EPL-5900L

1 A4, GDI, 2(13) , 600 dpi. 12

4 Canon LBP-810

1 A4, GDI, 600 dpi, 8 ppm, 100

5 Brother HL-1240 Mono Laser

1 A4. 26, 600x600 dpi, 12 ppm.

6 Epson AcuLaser C1000w

1 A4, , 16(256) , 600 dpi/2400 dpig

7 Epson AcuLaser C2000

1 4, , 64(512) , 600 dpi/2400 dpi

. 5.4. Print Preview,


Print Preview , -, QRPreview,
QuickReport. ,
, Quick Report .
Print Preview, .
. , , .
, (Zoom to fit)
(Zoom to width), , , (100%).

. , ,

5.

279

. Print Setup
. ,
Print. , qrp (
Quick Report). , Save Report.
t/r/7- Print Preview Load Report.
Form2, , . ,
BDE. BDE , ,
SQL. , , ,
Interbase, (IBLocal).
, .
, ( , Quick Report).
BDE, , SQL. SQL ,
, .
,
.
, , . , .


.
( Form File \ New) TQuickRep.
TQuickRep, , . , 4 ( 1123 794 ). ,
TQuickRep .
.
dbExpress ( ). ,
TQuickRep, TSQLConnection TSQLDataSet,
.
. , MylBData, SQLDataSetl. CommandText :
SELECT SALES.SALEDATE, SALES.CHECKN, EMPLOYEE.LNAME,
ITEMS.ITEM, SALEPARTS.QTY
FROM SALES
INNER JOIN SALEPARTS
ON (SALEPARTS.SALE = SALES.SALENO)
INNER JOIN EMPLOYEE
ON (EMPLOYEE.EMPLOYEENO = S A L E S . E M P L O Y E E )
INNER JOIN ITEMS
ON (ITEMS.ITEMNO = SALEPARTS.ITEM)
WHERE SALES.SALEDATE BETWEEN ' 6 / 1 / 0 2 ' AND ' 6 / 3 0 / 0 2 '

280

Borland C++ Builder 6.

, SQL, :
. ,
CheckN Sales, LName Employee, Item Items i
SaleParts. , <
SaleDate Sales 01.06.02 30.06.02.
, 2002 .
Sales SaleParts, ;
SQL, 5.1.
5.1. ,
SALES SALEPARTS
CREATE GENERATOR SALE_GEN;
CREATE TABLE SALES
(
SALENO
PKEYFIELD,
SALEDATE
TIMESTAMP NOT NULL,
CHECKN
VARCHAR(IO) NOT NULL,
EMPLOYEE
FKEYFIELD,
COMMENT
VARCHAR(SO).
PRIMARY KEY (SALENO),
UNIQUE (CHECKN)

);

ALTER TABLE S A L E S ADD CONSTRAINT SALETOEMP FOREIGN KEY (EMPLOYEE)


REFERENCES EMPLOYEE (EMPLOYEENO)
ON UPDATE CASCADE ON DELETE CASCADE;
SET TERM ;
CREATE TRIGGER SET_SALE FOR SALES
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
NEW.SaleNo=GEN_ID(Sale_GEN,l);
END

SET TERM ;

CREATE GENERATOR SALEPARTS_GEN;


CREATE TABLE SALEPARTS
SALEPARTNO
PKEYFIELD,
SALE
FKEYFIELD,
ITEM
FKEYFIELD,
QTY
SMALLINT DEFAULT 1,
PRIMARY KEY (SALEPARTNO)
);
ALTER TABLE SALEPARTS ADD CONSTRAINT SALEPARTSTOITEMS FOREIGN KEY (ITEM)
REFERENCES ITEMS (ITEMNO)
ON UPDATE CASCADE ON DELETE CASCADE;

5.

281

ALTER TABLE SALEPARTS


ADD CONSTRAINT SALEPARTSTOSALES FOREIGN KEY (SALE)
REFERENCES SALES (SALENO)
ON UPDATE CASCADE ON DELETE CASCADE;

SET TERM

CREATE TRIGGER SET_SALEPARTS FOR SALEPARTS


ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
NEW.SalePartNo=GEN_ID(SaleParts_GEN,l);
END

SET TERM ;A
, Active SQLDataSetl
true. .
DataSet TQuickRep SQLDataSetl (
, ).
, , TDataSource.
.
, TQuickRep.
(DetailBand). ,
, . , ,
: (ColumnHeaderBand)
(TitleBand).
,
. , ,
, .
TQRBand.
Bands TQuickRep. Bands 6 , Has. -
true, . true
HasDetail, HasColumnHeader HasTitle.
.
TQRDBText ( QReport), . TQRDBText TDBEdit Data Controls. AutoSize
TQRDBText true.
, ,
. ,
TQRDBText SQLDataSetl ( DataSet).
, DataField TQRDBText
, . ,
, ( ) TQRDBText
: CheckN, SaleDate, LName, Item, Qty.

282

Borland C++ Builder 6.

ColumnHeaderBand. :
TQRLabel, !!!
, DetailBand. :
( Caption): CheckNo, SaleDate, Employee, Item Quan
tity. , Frame
true DrawBottom DrawTop. ]
TitleBand TQDLabel. Caption *
. 2002 . . , Font TQRLabel. ,
12 fsBold.
, ,
Preview TQuickRep. :
Form2->QuickRepl->Preview() ;
. 5.5, . 5.6.
pjfp^r~

|*

t"heckNo!TfealeDate
Employee
bhlECKN ^ALEDATEtNAME

. J*5>ft
_ _ _ . _

,__::

Htem

ITEM

.__-*=--

- _; *

. 5.5. ,
TQuickRep, .

TQuickRep
, TQuickRep,
. .
TQuickRep DataSet Bands. DataSet
(BDE, dbExpress ..).
Bands ,
TQRBand. Bands, ,
Has. ,
( , .. TQRBand,
).

5.

283

~l'. 2002 .

||
*

'

<

>

| \ ~ gosej
2002 .

1
1

CheckNo SaleDate

Employee

Chk-166
Chk-166
Chk-166
Chk-166
Chk-167
Chk-168

01.06.02

01.06.02
01.06.02
01.06.02
02.06.02
02.06.02

Chk-168
Chk-168

02.06.02
02.06.02

_J
Epson Stylus Photo 810
Socket 423 (Pentium 4) Intel DSSOGBG^;;
Epson Stylus Color C80
Canon CanoScan N656U
Intel Pentium 4 1.6 GHz
HP DeskJet 980C
Socket 478 (Pentium 4) Abit 7H7II
jH
Canon CanoScan D646U

Chk-168
Chk-169

02.06.02
02,06.02

DIMM128MbPC133. NCP
17"(16") Samsung 753DFX

Item

ll^.,..

" V V . . . :';;.,,;.

\^*&*~
. 5.6.
Q PageHeaderBand ( HasColumnHeader).
,
. , FirstPageHeader Option TQuickRep. true, ..
.
TitleBand ( HasTitle). TitleBand (,
) ,
, . TitleBand
.
Q ColumnHeaderBand ( HasColumnHeader). , , ,
( ), (. ). TQRLabel,
.
Q DetailBand ( HasDetail). ,
, , DataSet TQuickRep. TQRDBText,
, DataSet. , .

284

Borland C++ Builder 6.

;
( ).
U SummaryBand ( HasSummary).
, .
.
PageFooter ( HasPageFooter). :
. LastPageFooter ;
Options TQuickRep false, !
.
,
, . ,
TQuickRep. , )
. dbExpress. Hz
TSQLConnection TSQLDataSet. , , MylBData
SQLDataSetl SQLConnectionl,
CommandText :
SELECT SALES.SALEDATE, SALES.CHECKN, ITEMS.ITEM,
SALEPARTS.QTY, ITEMS.PRICE
FROM ITEMS
INNER JOIN SALEPARTS
ON (SALEPARTS.ITEM = ITEMS.ITEMNO)
INNER JOIN SALES
ON (SALEPARTS.SALE = SALES.SALENO)
WHERE SALES.SALEDATE BETWEEN ' 0 1 . 0 6 . 0 2 ' AND ' 3 0 . 0 6 . 0 2 ' ;
SQL ,
. ,
SaleDate, CheckN, Item, Qty Price.
, 2002 . ,
Active true.
Bands true.
.
. PageHeaderBand
TQRSysData. , .
TQRSysData Data. ,
Data, , ,
TQRSysData. :
qrsDate .
U qrsTime .
Q qrsDateTime .
Q qrsReportTitle , ReportTitie
TQuickRep. Print Preview.
U qrtPageNumber .
.

5.

285

Q qrtDetailNo ,
. .
Q qrsDetailCount , .
. TQRSysData,
, , Data qrsDate. Data TQRSysData,
, qrsReportTitle. ReportTitle TQuickRep -
, , 2002 ..
. , Frame
PageHeaderBand DrawBottom true. .
,
false FirstPageHeader Options TQuickRep.
. PageFooterBand
TQRSysData. Data qrtPageNumber.
, true
DrawTop Frame PageFooterBand.
(TitleBand) TQRLabel Caption , ReportTitle TQuickRep.
.
,
. DetailBand
TQRSysData, TQRDBText
TQRExpr. . ColumnHeaderBand
TQRLabel, ( Caption) ( ): , SaleDate, CheckNo, Item, Quantity, Price Cost.
,
TQRLabel fsBold ufsltalic.
Data TQRSysData, ,
qrtDetailNo. .
( TQRDBText)
SQLDataSetl ( DataSet). ( DataField) ( )
: SALEDATE, CHECKN, ITEM, QTY, PRICE.
, ,
TQRExpr. , , , .
TQRDBText, TQRExpr DataSet.
Expression , .
.
Expression ,
(Expression Wizard).

286

Borland C++ Builder 6.

Enter expression;
SQLDataSetl .QTY" SQLDataSetl PRICE

Insert a* cursor position


V'Databasefield
* I /

- j 5

> I <> I <- I >- I NotlAndj Or

. 5.7.

Insert database Weld in expression


Select dataset

Available fields
SALEDATE
CHECKN
ITEM
QTY

PRICE

. 5.8. ,
.
MEMO,
(. 5.7).
,
. Database field
, -

5.

287

. ,
(. 5.8). ,
, .
, , ,
, ,
, .
Lxpression Wizard
-Select functionCategory

Date & time


Math & trig
Statistical
Database
Logical
Information
Other

STR
UPPER
LOWER
PRETTY
TIME
DATE
COPY

rns <X> or <Y> depending on the boolean expression

5.9.
Function
(. 5.9).
, Continue.
(. . 5.7). ().
, , Variable
.
(. . 5.10): PAGENUMBER (
), COLUMNNUMBER ( ), REPORTTITLE ( ),
APPSTARTTIME ( ), APPSTARTDATE ( ) APPNAME ( ).
,
. Modify variables.
TQRExpr ,
,
. Expression :
SQLDataSetl.QTY * SQLDataSetl.PRICE
.
(SummaryBand). ,
, .

288

Borland C++ Builder 6.

COLUMNNUMBER
REPORTTITLE
APPSTARTTIME
APPSTARTDATE
APPNAME

. 5.10.

TQRExpr TQRLabel, . !
, Font TQRExpr fsBold ufsltalic,
Font TQRLabel fsBold HfsUnderline. Caption
TQRLabel .:, Expression TQRExpr :
SUM(SQLDataSetl.QTY * SQLDataSetl.PRICE)
. , Preview TQuickRep. .
5.11 ( ) 5.12 ( ).

PreviewModal PreviewModeless. Print Preview


, Print Preview ,
PreviewModeless . Preview
, Preview (thread),
PreviewModal PreviewModeless .
(not thread safe),
Preview.
, . Print TQuickRep.
, . , PrinterSetup.

5.

289

JReport title);
'Page Header

2002 .
"SaleDate

"CheckNo

Item

"Quantity
T

pet "SALEDATE^CHECKN ] JTEM

Price

QTY

Cosi

T>RICE

"^QLDataSef

": SUM(SQLDataSet1.QTY'
'

'

Page F,it>!(

. 5.11. , TQuickRep

? 2002 .

;Be[ffli < . > !

@*[

Close)

* 2002 .
ChecWo

24.04.03

Mm

Quantity

Price

Cos*

45

34.06.02

Chk-177

>| !WinbondS200F

68

38

46

34.08.02

Chk-177

AMD Alhlon 950 MHz

71

71

47

34.08.02

Chk-177

Epson AcuLaser C2000

2156

4312

48

34.06.02

Chk-177

Pinnacle Studio DV500 Plus professional

759

i5ie

49

34.08.02

Chk-17B

17'(1B') Samsung 755 DFX

204

204

50

34.08.02

Chk-178

Inno VISION Tornado ASP 32 Mb

46

46

61

34.08.02

Chk-178

Socket A PC Parser 91 1/100

64

182

52

34.08.02

Chk-178

DVD-ROM Diiw LG DRD-8160B

85

195

63

34.06.02

Chk-178

VIA MHz

42

54
55

34.06.02
35.06.02

Chk-179

24

Chk-180

KB6869 /
Fast EthernetC omplex

14

42

56

35.06.02

Chk-181

Epson SVIusPhoto810

122

368

57

35.08.02

Chk-181

Socket 478 (Pentium 4) I ntel D893MVL

168

504

53

35.06.02

Chk-182

Fast Elheinet Surecom EP-320JX, S1 2

18

59

35.06.02

813

1839

JO.UO.U^

HUB HP PmCunre Siitch 2324(J4318A)


Fast ElhernetSCom ElherLinh

OU

Chk-182
Chk-182

42 '

84

185%|Pagefof'

^^^^^^

5.12. , TQuickRep

10 *. 319

pi
'

290

Borland C++ Builder 6.

(Printer Setup).
, (
, , ..).

PrinterSettings Page. ,
. PrinterSettings TQuickRepPrinterSettings.
TQRPrinterSettings, TQuickRepPrinterSettings : Copies ( ), Duplex (
, ), Firs/Page LastPage (
), OutputBin ( ).
Page . 11 ,
(Page Setup). :
Q TopMargin, LeftMargin, BottomMargin, RightMargin , ,
;
U Column ColumnSpace ;
Q PaperSize ; : 4, A3, 5, 4, Custom ..;
Q Length () ;
, PaperSize Custom;
Q Width ;
Q Orientation : (poLandscape) (poPortrait);
Q Ruler true, ()
.
Options, . , FirstPageHeader LastPageFooter. Compression. true,
.
Printer TQRPrinter, , ,
. TQuickRep PrintlfEmpty.
true, (, ..), .
TQuickRep , . , ,
. . TQuickRep.
TQuickRep . OnPreview
Preview. , , :
Print Preview . , ,
Preview . OnPreview
. OnPreview QuSoft www.qusoft.com.

5.

291


AfterPreview, TNotifyEvent. - , .
Print : BeforePrint AfterPrint. , BeforePrint
Preview. Print, Preview, PreviewModal PreviewModeless .
:
void

fastcall TForm2::QuickReplBeforePrint(TCustomQuickRep *Sender,


bool &PrintReport)

Sender, TCustomQuickRep, PrintReport .


false, . BeforePrint
, , - , , .
, AfterPrint.
/ .
OnStartPage , .
TNotifyEvent.
, ,
. OnEndPage ,
. ,
. , , OnNeedData
, . www.qusoft.com.


, Bands TQuickRep ,
, , . , TQuickRep TQRBand.
TQRBand BandType TQRBandType.
, ,
Bands. ,
, BandType TQRBand, : rbPageHeader ( ), rbTitle ( ), rbColumnHeader ( ), rbDetail ( ), rbSummary ( )
rbPageFooter ( ).
, BandType TQRBand, :
Q rbSubDetail
TQRSubDetail. .

Q rbGroupFooter , ( TQRGroup TQRSubDetail).


, .

292

Borland C++ Builder 6.

G rbGroupHeader , ( TQRGroup TQRSubDetait).


,
.
Q rbOverlay Quick Report 1.0. .
rbChild TQRChildBand. .
rbGroupHeader rbGroupFooter.
. rbGroupHeader TQRGroup.
.
, .
dbExpress (,
- ) BDE.
, , . 5.12,
TSQLConnection TSQLDataSet.
TQuery BDE. Query 1
MyData, , MylBData Interbase, .
SQL Query 1 :
S E L E C T S A L E S . S A L E D A T E , S A L E S . C H E C K N , ITEMS.ITEM,
S A L E P A R T S . Q T Y , ITEMS.PRICE
FROM ITEMS
INNER JOIN SALEPARTS
ON (SALEPARTS.ITEM = ITEMS.ITEMNO)
INNER JOIN S A L E S
ON ( S A L E P A R T S . S A L E = S A L E S . S A L E N O )
WHERE S A L E S . S A L E D A T E BETWEEN ' 0 1 . 0 6 . 0 2 ' AND ' 3 0 . 0 6 . 0 2 '
ORDER BY S A L E S . S A L E D A T E ;

SQL- ORDER BY, SALEDATE (


). , derive Query 1
true. DataSet TQuickRep
TQRDBText. , (Summary), SQLDataSetl.
(
SaleDate).
, .
, , TQRGroup ( )
TQRBand. BandType TQRBand rbGroupHeader ( TQRBand (rbTitle)).
.
Group Header,
, Expression. ,

5.

293

Expression Wizard (. .
5.7). ' .
- . SaleDate.
, Expression, : TQRGroup , . TQRGroup SaleDate, SQL Query 1,

( ).
Expression , ( ,
).
TQRGroup ,
() . , .
TQRDBText,
SaleDate. ,

. ,
fsBold wfsltalic. ,
.

, (Group
Footer). TQRBand, ,
BandType rbGroupFooter.
.
. TQRGroup ,
FooterBand, .
Group Footer , .
. .
,
Summary . ,
TQRDBText
, , , Reset After Print TQRDBText true.
, ..
.
. ,
, . . 5.13.
. , SaleDate ,
.
TQRGroup TQRBand, BandType rbGroupFooter. Expression TQRGroup
CheckN. -

294

Borland C++ Builder 6.

' . 2002 .

A.

29.04.03

2002 .

* 2002 .

SafeOate

Quantity

Price

CftecMVo

Hern

Epson Stylus Photo 810


Sock si 423 (Pentium 4) Intel D8906BC

122.0O$

132 .00$

396

Canon CanoScan N95611

87.00

261

Epson Stylus Color CSO

185.00

740

CO*

01.0U02
1

oi.oe.02

*-1

01.06.02

01.06.02

(-1
ci*-iee

01.06.rJ2

Chk-166

1763

02.002
5

02.00.02

Ct*.172

ISPOS") Samsung855DF

298.00

2.06.2

CN<-174

CMedia Thundering

12.00

43

02.06.02

Cr*-iee

Sooket478(Pentium4)ChaintechCT-9BIA 2

107.00

214

02.06.02

Cr*-170

Pinnacle Mto Video Studio DC10 Plus

432

02.06.02

Cr*-172

Epson Stylus Cob(

2
1

201.00

148.00$

148

10

02.06.02

Chk.168

DlrVM 128 H* PC133. HCP

34.00

13

11

02.06.02

CHi-171

Socket 370 FC-PGA/PPGAPC Partner

4
1

Page i of 1 ?

58.00

894

-;:';*; |S ' J

_u

. 5.13.

, . , , (..
), .
.
FooterBand . ,
, . Summary
. , ResetAfterPrint
true. ,
. . 5.14.
TQRBandvi TQRGroup, QReport
, .
TQRSubDetail Master/Detail.

(, TQuery TSQLDataSef).
TQRChildBand ,
ParentBand .
, , . -

5.

295

' 2002

<

2002 .

2002 .

SafeDsfe

/fern

Quantity

Prro?

Cos*

01.06.02
Chk-166
1

01.06.02

Chk-166

CanonCmoSoanNeseu

87.00*

261

2
3
4

01.06.02
01.06.02
01.06.02

<-1
CN<-1
-1

Epson SVIus Color C80


So*et423 (Pentium- Intel 0890GBC
Epson SVIus Photo 810.

185.00*
132.CO*
122.00*

740
396
336

1763
1763

02.06.02
Chk-167
6

02.06.02

Chk-187

lntelPenlium41.6 GHz

173.00$

173

. 5.14.
, true HasChild ,
.
, , LinkBand.
TQRStringsBand ,
Items, TStrings*.
, , .
TQRStringsBand . Expression TQuickRep ,
, . .
: BeforePrint AfterPrint. .
PrintBand .
BeforePrint false, .
AfterPrint , BeforePrint. BandPrinted
, .
.
BeforePrint,
:

296

Borland C++ Builder 6.

void _ fastcall TForm2 : :QRBandlBeforePrint(TQRCustomBand *Sender,


bool &PrintBand)

PrintBand=
((Queryl->FieldByName(SALEDATE)->

AsDateTime >= TDateTime(01 .06.02))


&&
(Query !->FieldByName(SALEDATE)->
AsDateTime = TDateTime(36.06.02))) ;

Quick Report

TQuickRep, (TQRBand, TQRGoup, TQRSubDetail, TQRStringsBand,
TQRChildBand), TQRLabel, TQRDBText, TQRExpr,
TQRSysData. QReport .
.
, Quick Report.
TQRMemo, TQRExpr Memo, TQRRichText TQRDBRichText
. Quick Report .
Lines. TQRExprMemo Lines Quick Report.
Quick Report .
,
( TQuickRep).
, :
Supplier:
City:
Address:
Contact:

{Supplier}
{City}
{Address}
{Contact}

TQRRichText TQRDBRichText Quick Report TRichEdit TDBRichEdit .


TQRRichText Lines, TQRDBRichText .
TQRShape, TQRImage TQRDBImage
. TQRShape , Shape: (rbsRectangle), (rbsdrcle), (rbsVertLine), (rbsHorLine),
TQRShape (rbsTopAndBottom),
TQRShape (rbsRightAndLeft). TQRImage TQRDBImage , *.jpg, *.jpeg, *.bmp,
*.ico, *.emfu *.wmf. TQRImage ( Picture),
TQRDBImage ( DataSet DataFiela).
TQRCompositeReport (
TQuickRep) .

5.

297

, . - Reports,
(TQuiickRep). .
Add.
Print,
Preview. , QRCompositeReportl,
QuickRepl ( Form!) QuickRepl ( Form2),
.

QRComposi teReportl->Reports->Add(Forml->QuickRepl);
QRCompositeReportl->Reports->Add(Form2->QuickRep2);
QRCompositeReportl->Preview();
, ( , Borland C++ Builder, ), TQRPreview.
,
.
QuSoft www.qusoft.com. TQRChart, . TQRChart
(TDBChart DataControls
TChart Additional ).
QReport QRTextFilter, QRCSVFilter
QRHTMLFilter. (ASCII), * csv ( ) HTML. , (Print Preview)
: Text file (*. TXT) (
QRTextFilter), Comma Separated (*.CSV) ( QRCSVFilter) HTML
Document (*.HTM). , .
Create,
ExportToFilter.

Decision Cube
, Decision Cube , .
Microsoft Excel,
Microsoft Office Web Component. ,
Decision Cube.
Decision Cube : TDecisionCube, TDecisionQuery,
TDecisionSource, TDecisionPivot, TDecisionGrid TDecisionGraph. TDecisionQuery
, SQL. SQL,
DatabaseName. TDecisionQuery , Active true. TDecisionQuery ( ,
) TQuery
BDE.

298

Borland C++ Builder 6.

TDecisionQueiy , , (
Decision Query Editor). Dimensions/Summaries SQL Query (. 5.15).
Dimensions/Summari
List of Available Field
Sales.SaleNo
Sales.SaleDate
Sales.CheckN
Sales.Employee
Sales.Comment
Saleparts.SalePartNo
Saleparts.Sale
Seleparts.ltem
Saleparts.Qty
Items.ItemNo
Items.ltem
Items.Category

Items. Item

Summaries:
SUM( Items.Price *Saleparts|

" Count (*} tor Averages


Uuety Fie Iris

SQL Builder.

Cancel

. 5.15. Decision Query Editor,


Dimensions/Summaries, SQL

Dimensions/Summaries SQL. TQuery,


SQL, TDecisionQuery, (GROUP BY)
(SUM, AVG, COUNT). , Database Table.
List of
Available Fields. Decision
Cube, . (dimensions)
,
. ( ,
), , SQL
SELECT, GROUP BY. ,
, SELECT (SUM, COUNT v. .).
SQL, SQL Builder. , TQuery.

299

5.

TDataSource Decision Cube TDecisionSource.


TDecisionQuery ,
TDecisionCube. TDecisionCube SQL
TDecisionQuery, TDecisionSource . TDecisionCube Decision Cube Editor,
DimensionMap,
,
Decision Cube Editor.
( , ..), ( , , ..).

: 2002a;p
I^^^SSSi

.2002

Fujitsu f

3.8") LG St

113.00$

3.8")LGSt

928.00$

.aer,2002

792.00$

396.00$

113.00$

1,017.00$

1,482.00$

6,422.00$

580.00$

wnsung15
unsung 15

,2002

2.048.00$

2,560.00$
487.00$

1,948.00$

imsung 55

1,120.00$

980.00$

700.00$

unsung 55

615.00$

984.00$

492.00$

imtron 5SE

714.00$

714.00$

238.00$

inySDM-N

4,805.00$

imsung 1 5

961.00$

3") Sarnsti
S"VC;m<!i,

1 nnt

988.00$
1,024.00$ J
420.00$

961.00$

2,079.00$

756.00$

|fj

'"""^:

. 5.16.
Decision Cube :
T D e c i s i o n Q u e r y -> TDecisionCube -> TDecisionSource
TDecisionSource
TDecisionGrid TDecisionGraph.
TDBGrid,
( , TDBChart).
.

TDecisionQuery, TDecisionCube, TDecisionSource TDecisionGrid,
. , SQL
TDecisionQuery, :
SELECT Sales.SaleDate, Items.Item, SUM( Items.Price * Saleparts.Qty )
FROM Sales
INNER JOIN Saleparts
ON (Saleparts.Sale = Sales.SaleNo)

300

Borland C++ Builder 6.

INNER JOIN Items


ON (Items.ItemNo = Saleparts.Item)
GROUP BY Sales.SaleDate, Items.Item

( DatabaseName) MyData Active DecisionQuery1 true. ,


SQL,
. , .. .
.

-
.~i,j-..-ii

TOecisionGraph

255.718 , 2002
275.557 . 2002
334,839 , 2002
128,592 . 2002

, 2002

, 2002
, 2002
SaleDate

, 2002

. 5.17. ,
TDecisionGraph
DecisionCubel. DecisionQuery 1 (
DataSei) Decision Cube Editor Dimension
Settings. Available Fields SaleDate
( Month
Grouping). , ,
.
DecisionGridl DecisionSourcel, aero,
, DecisionCubel. . 5.16.
, Items
, SaleDate .
, .
, , .
,

5.

301

.
.

+ -. , ()
() , .
. Drill in
to this value, .
. , .

TDecisionGrid, Decision Cube
.
TDecisionGraph. , .
TDecisionGrid,
TDecisionGraph, DecisionSourcel. SQL DecisionQueryl Item Items (
Item ). , Active
DecisionGraphl true. . 5.17.
, -, .
TDecisionPivot.
.
, , TDecisionGrid. TDecisionPivot, DecisionSourcel. SQL
DecisionQueryl :
SELECT Sales.SaleDate, Items.Item, SUM( Items.Price * Saleparts.Qty ),
COUNT( Items.Price * Saleparts.Qty )
FROM Sales
INNER JOIN Saleparts
ON (Saleparts.Sale = Sales.SaleNo)
INNER JOIN Items
ON (Items.ItemNo = Saleparts.Item)
GROUP BY Sales.SaleDate, Items.Item
SQL , ,
. DecisionCubel
. DecisionQueryl, Active
true. . 5.18.

302

Borland C++ Builder 6.

Form!

Item

" 0

(
10.0Gb Fujitsu f>/

, 2002

:15"(13.8")LGSt
j15"(13.8")LGSt
; 15" Samsung 15
! 15" Samsung 15
15" Samsung 15
; i15" Samsung 55
i15" Samsung 55
j15"Samtron5BE
;15"SonySDM-h
;17"(16")Samsu
:

'

113.00$

'

2002

[Jiijl

SaleDate

:
792.00$

396.00$

113.00$

339.00J

1,402.00$

1,605.50$

988.00$

2.048.00$

1.024.00$

464.00$

290.00$

853.33$
-187.00$

974.00$

373.33$

26.7$

350.00$

307.50$

328.00$

492.00$

23B.QO$

238.00$

238.00$

1,B01.67t

961.00$
519.75$

.; 1

210.00$

961.00$
378.00$
1

. 5.18. TDecisionPivot

TDecisionPivot .
. , .
. : ,
.
.
,
. .
, , . , /
,
, .
Decision Cube, ,
.
,
, . ,
Decision Cube.


Quick Report Decision Cube. , ,

5.

303

. . TQuickRep,
. ,
, (TQRLabel, TQRDBText, TQRExpr TQRSysDatd). ,
TQRBand TQRGroup . Quick Report, .
, Decision Cube
, . TDecisionCube, TDecisionQuery, TDecisionSource, TDecisionGrid, TDecisionGraph
TDecisionPivot .

TSQLQuery 261
TSQLStoredProc 261
TStatusBar 75,130,284
TTable 34,42,159
TUpdateSQL 182

168

164
164
85

217

163
209

229

34
TField 75,78
TDataSet 34
TDBGridColumns 143
34
TBatchMove 132,189
TDataSource 42,72,131,262
TDBChart 131
TDBCtrlGrid 135,270
TDBGrid 136,291
TDBLookupComboBox 91,131,263
TDBLookupListBox 130
TDBNavigator 40,129
TDBRadioGroup 131
TEdit 42
TListView 49,105,246, 282
TSession 114, 115
TSQLConnection 236,240

ARRAYOFCONST 62,68
OPENARRAY 62,68

Abort 69
AddAlias 100,119,120
AddFieldDef 101
AddlndexDef 101
AddStandardAlias 100,119,120
AnsiPos 64
Append 68
ApplyRange 51,264
ApplyUpdates 94
Assign 80
Bookmark Valid 71
Cancel 67
CancelRange 51, 119
CancelUpdates 94
Clear 81
Commit Up dates 94
Date 88
DecodeDate 88
Delete 68
DeleteDatabase 121, 144
DeleteTable 67,120
DropConnections 121
Edit 68
EditKey 60,247,254
EditRangeEnd 51,121,264
EditRangeStart 51, 118
FieldByName 49, 118

FieldByNumber 49,111
FindFirst 63,267
FindKey 61
FindLast 63,146,155
FindNearest 61,120
FindNext 63,110,261
FindPrior 63
GetFieldNames 111
GotoKey 60
GotoNearest 61
Insert 67
IsAlias 100
IsEmpty 88
IsNull 88
LoadFromFile 143
LoadParamsFromlniFile 236
Locate 62,142
Lookup 62
MoveBy 41,110
OpenDatabase 121,267
Post 67
Prepare 182
RemoveAllPasswords 118
RenameTable 67
RestoreDefaults 143
SaveConfigFile 120
SaveToFile 143
SetKey 60
SetRangeEnd 51,181
SetRangeStart 51
StartTransaction 110
Substring 88

MyBase 263
263
103

20,24

ALTER TABLE 175,227


ALTER TRIGGER 223
CREATE DOMAIN 209

CREATE EXCEPTION 222,229


CREATE GENERATOR 218
CREATE INDEX 175,211,216
CREATE PROCEDURE 223
CREATE ROLE 232
CREATE TABLE 173,210
CREATE TRIGGER 219
DROP INDEX 176
EXCEPTION 222,229
EXECUTE PROCEDURE 222
FOR SELECT ... DO 221
Full Outer 165
Inner 164,230
Left Outer 164
Outer 164
REVOKE 232
Right Outer 165,215
SET GENERATOR 219
SUSPEND 222,225
WHEN 222
WHEN ...DO 229
WHENGDSCODE 230
WHEN SQLCODE 230

Between 165
Exists 165
In 166
Is [Not] Null 167
Like 166

82
82
82
89
177

From 162
Having 168
Group By 168
Order By 169
Select 161
226
20,21,106

305

306

Borland C++ Builder 6.

48,82
136
93
231

ActiveStatements 247
AllowStreamedConnected 238
Aslnteger 53
AutoEdit 74
AutoGenerateValue 79
Bof 41
Bookmark 70,130
ButtonStyle 138,263
CachedUpdates 93,183
CanModify 69
Columns 136
DataType 79,138
DefaultExpression 80
Delta 267,282
DriverName 106,267
Eof 41
FieldDefs 82,101
FieldKind 79,150,270
Fields 47,106
Filter 57
Filtered 57,105
FilterOptions 57,58,140
IndexDefs 101
IndexFieldNames 50, 60,115, 246
IndexName 50,60,130
Islndex 80
IsNull 80
KeepConnection 235
KeepConnections 116
ListSource 130
LoadParamsOnConnect 235
LookupCache 91,267
Options 144

Readonly 69,190
RecNo 156
RequestLive 179,263
RowsAffected 182
SessionName 115,235
State 72
UpdateObject 187,188
UpdatesPending 94
ViewStyle 49,106,246

-- 73
20, 24

AfterPost 96,158
AfterScroll 44,250
BeforeApplyUpdates 267
BeforeUpdateRecord 269
OnCalcFields 85,149,152
OnCellClick 158
OnChange 81
OnClose 59,113,273
OnColEnter 158
OnColumnMoved 158
OnCreate 59
OnDataChange 74,114,249
OnDrawColumnCell 153
OnEditButtonClick 139,140, 267
OnFilterRecord 60, 63,188, 268
OnGetText 81,116
OnReconcileError 78,267
OnSetText 82
OnStateChange 74,114
OnUpdateData 74,191
OnUpdateError 78,95
OnUpdateRecord 94
OnValidate 81,117, 118, 271

TLocateOptions 62
109

219

Cast 172
Extract 172,249,251
Lower 171
Substring 171
StrToIntDef 44
Trim 172
Upper 171

X
223

Database Desktop 26
SQL Explorer 20

307

.
.
ISBN 5-93772-049-fl

70x100/16, , 896 .

SAMS
.
. ,
. (, ..), . ,
, . -

,
web- www.diasoft.kiev.ua.
,
99.
.
,
.


1.
2.
3.
4. /
5. ,
6. :
7. :
8. /
9.
10.
11.
12. ,
13. /
14.
15.
16.
17.
.
.
.

C++.
.
ISBN 5-93772-073-3
70x100/16, . , 1104 .

SAMS
C++ ,
ISO/ANSI.
C++. ,
. ,
C++, C++,
, , , -

, , STL, RTTI .

.
. , ,
.
, .


1.
2. C++
3.
4.
5.
6.
7. C++
8.
9.
10.
11.
12.
13.
14.
C++

15. ,

16. string
17. /
.
. C++
. ASCII
D.
.
F. STRING
G. STL
.
I.
ANSI/ISO C++
J .

#.
.
ISBN 5-93772-052-0
70x100/16, ,

656 .

SAMS
#, ,
.NET. ,
- , , "" . - , , , , ,
, -

. , , ,
, . , #.


1. :
2. #
3. #. I
4. #: II
5. - #
6. . I:
7. . II: ,
8. . I:
9. . II:
.
10. . I:
11. . II: ,
12. . I:
13. . II:
14. . III:
15. ,
16. . I:
17. . II: , ,
18.
19.
20.
21. , XML-
22. -
23.
.
.
. #
D.
. Unicode
F. DOS

C+ +

C++
/ /
/

tail 1-4
tarn
Ei ||
i|u
: tllllpnl

kn

, :
, ?
? ?
? :
,

.
, , " ", ,
.
, . ,
( ) .
,
- .
(, ),
"", "", "" .
""
"" (, !)... , ? , ? , ,
( , -

ISBN 966-7393-89-5
70x100/16, . ,
688.



,
""
, ,

, )? ' ?
: () , ,
.
,
. ,
.
,
"". ,
, .
( , ).

C++.

ISBN 5-93772-054-7
70x100/16, .
496,

unpm
<|

, , , .
, , .
, , , , - .
C++ .

, :
, ; ; . , .
(
, ), ,
.

5.
17.
18.
19.
20.
21.
22.
,

. 1-5
/ ///

ISBN 5-93772-083-0
70x100/16, . , 1136 .


, , , "". , , .
, , , , -
. "".
. , .
( , ),
"", .

. 1-4
/ //
ISBN 5-93772-081-4
70x100/16, . , 672 .

. 5

ISBN 5-93772-082-2
70x100/16, . , 480 .

@
( - )
@. ,
. i
. :
, -, <
www.diasoft.kiev.ua.
:

;
, ;
;
;
.

, , ,
, , - , (
), , , ..
www.diasoft.kiev.ua


,
, , ,
.
, .
(
). ( , ,
) " ,
, . , , .


, 5%
( + 1000 ).
; .
10% .
,
www.diasoft.kiev.ua.

1.
.
2. , , ( ) ?_
3. ...
4.
5.
6. , , e-mail, web-
"
: , 03055, -55, / 100, .

. _| 1 1 \

. \ci/
1

""

.
, 1

AL^V

-
-
- , 105, . , .""
190103. - , 44, / 66,000 ""

,
(

'

9>
:S '

S:l
W

./. 212-12-54, 216-35-64


-: 03055, \ 100
e-mail: books@diasoft.kiev.ua
e-mail: bss@diasoft.kiev.ua
e-mail: stepanb@akcecc.kiev.ua

.(0562)33-27-74, 34-02-09
-: 49008, \ 466
e-mail: diasoft@mail.dnepr.net
.
. (0572)47-20-67
e-mail: books@rail.kharkov.com

./. (0322)39-87-08
e-mail: vlas@txnet.com

. (095)726-80-67
e-mail: diasoft_msk@rosmail.ru
-
.(812)251-41-94
e-mail: diasoft_spt@mail.convey.ru
190103, \ 66
000 " "

"', . , 46
. (044)224-22-91
" ",
.,51 . (044)227-25-1
"", - , 29
. (044)274-52-35
" ",
- 40- , 100/2
. (044)263-20-54, 263-20-04
./ (044)263-60-56

" ",..
. (0572)47-80-20

" ",
., 1
. (0562)33-09-55
" "
.. 40
. (0562)744-86-72
"", - , 98,
. (0562)43-63-81

"'. 83
. (0622)382-64-69


"-"
. 1
. (0564)92-37-32

" ", .,10


. (0322)72-54-06
"",
, 4,5,
. (0322)39-8708

"Books", . , 51,
. (0572)14-04-71

"", ..6
. (095)928-87-44
" ",
-, 40, . (095)137-60-38
" ",
. , 8
"", -, 78
. (095)152-45-11
" * .2- ,54
. (095)978-50-47, 978-55-07
" ", . ,28
. (095)238-11-44, 238-00-32

-
" ", -, 28
.(812)318-64-16
" ",
. , 2,
.(812)164-65-65
"", -, 189
.(812)443-01-47

" XXI"
- ., 92,
.. ,
. (0172)64-31-05, 64-27-97

1) - ,

2) .
3) ,
e-mail.
4) mail.

1
5) ,
, .

0 - ,
( . , )
2)
3) ,
e-mail.
4
)
e-mail.

.
! .
5) , , .

, , .
.
, .
7 .
.

2003

:

:

- :

:

:/

E-mail: _

- :
.:03055/ 100, ./(044)212-1254,216-3564-1:
books@diasoft.kiev.ua
stepanb@akcecc.kiev.ua
190103, / 66 " "

www.diasoft.kiev.ua

4043
7277
6173
7261
7276
6169
6583
4020
4683
6538

- ""

., /: .

. 2-;

.
.. . 2-

, , , >


, +. . ,
., ; , 8 .
"

584
496
736
624
704
688
816
548
544
432

84x108/16
70x100/16
/0x100/16
70x100/16
/0x100/16
84x108/16
84x108/16
84x108/16
60x84/16
70x100/16


Microsoft Windows 2000 Professional.
.
Microsoft Windows 2000 Server.
. . Windows XP Professiona
Teppf Microsoft Windows XP
Linux.

( Linux. . 2- . flononh
.
Red Hat Linux . ,
.
Red Hat Linux 7
Jnux IP Stacks
( + CD-ROM )

.inux 5.2. + 2 CD-ROM
, fit Red Hat Linux 7.x
. , Unix .
, UNIX Internet ^+ CD-ROM
44 .
OS/2 Warp
r
6496
reeBSD.
6982 Solaris 8.

832
672
336
848
752
720
672
448
288
688
880
864
496
352
736
928

70x100/16
70x100/16
70x100/16
70x100/16
70x100/16
70x100/16
84x108/16
70x100/16
70x100/16
84x108/16
70x100/16
60x84/8
84x108/16
60x84/16
70x100/16
70x100/16

5511
5954
6521
6884
6455
6523
5717
6174
5758
3926
6718
1557
4318

5003
6522
5953
6704
6894
6905
7167
7168
6913
7464
7463
7465
6885
6914
5804
4754
3621
2757

.
Windows 2000.
640 84x108/16

Windows 2000 API. 2-


1088 70x100/16
. 1/+.
720 70x100/16
! #.
656 70x100/16
#.
912 84x108/16
" Visual ++6
496 70x100/16

Visual ++6 MFC


992 70x100/16
.
C++.
656 84x108/16
.
.
896 84x108/16
. 1-4. ,
672 70x100/16
. 1-5. , 1136 70x100/16
. 5.
480 70x100/16
C++. /
688 70x100/16
496 70x100/16
++. .
736 84x108/16
.
.
584 84x108/16
, C++
192 84x108/16
.
Delphi 4. ( )
.
400 84x108/16
Delphi 4. ( + CD-ROM )
512 60x84/16
93 .
Delphi
576 70x100/16
5845 . Delphi 6/7. .
192 60x84/16
7078 . . Qbasic Visual BaSIC
320 60x84/16
6964 . . Turbo Pascal. ,
208 60x84/16
6103 . Turbo Pascal 7.0 Delphi.
656 70x100/16
.
7063 ..
656 70x100/16
+ + CD-ROM
6148
288 70x100/16
Kylix 1 .0. .
5799

7251 Lotus Notes Domino 5\6 .


4303 Microsoft Office 2000.
Office XP. . . ... ..
6622 .

1024 70x100/16
52 84x108/16
432 70x100/16

.
256 "0x100/16
Word 2002. . ... ... ;
.
240 70x100/16
Excel 2002. . . ... ..
6104 < ..
.
656 70x100/16
6623 . . Access 2000. .
544 84x108/16
5096 . " Access 2000. ;
-.
800 84x108/16
4925 , OracleS . ( + CD576 84x108/16
Oracle 8/8i Server.
5057 "
864 60x84/8
Oracle 8. . . 2-, .,
6168 AIS
560 70x100/16
6728 5
Oracle 9i
Oracle . 1
672 70x100/16
7217
816 70x100/16
6965 . SQL.-99. .
688 70x100/16
5640 MS SQL Server 2000.
608 70x100/16
6729 " PostgreSQL.
800 60x84/8
2010 - . nformix.
.
496 84x108/16
2472 . Adobe Photoshop 5 ( + CD-ROM )
.368 70x100/16
6694
Adobe Photoshop 7.0.
762 70x100/16
7262 ; Adobe Photoshop 7.0. .
400 70x100/16
7218 Adob Illustrator 10
848 70x100/16
7219 - Adob Illustrator 10
528 70x100/16
7148 < . CorelDRAW 1 1
1024 70x100/16
7147 { . CorelDRAW 1 1
624 70x100/16
6171 , ; 3D Studio VIZ 3 + CD-ROM
570 .
3D Studio . 1 ( + CD-ROM )
752 84x1 08/8
649 . 3D Studio 2- ( + CD-ROM )
432 84x108/16
368 84x108/16
2860 .. X 3D Studio MAX 2. 2:
3925 3D Studio 2. 3: ( + CD-RC
408 84x108/16
720 84x108/16
5080 .
3D Studio MAX 3: ,
456 84x108/16
4634
3D Studio MAX 3 : ,
6925
3D Studio MAX 4/5 .
832 70x100/16
464 70x100/16
7278
3D Studio MAX 5. 2-
4 ( + CD-ROM >
336 70x100/16
5029 .
6170 . BRYCE + CD-ROM
656 84x108/16
5069 Flash 4 . ( + CD-ROM )
448 70x100/16
6094 ..
Flash 5.0. . . . ..
240 70x100/16
864 70x100/16
6195
Lightwave 6/7 :
6915 OpenGL
512 70x100/16
6803 By
OpenGL.
592 70x100/16
.
5163
704 60x84/16
PageMaker ( + CD-ROM )
6566 Ado Page Maker 7.0 . Adobe
384 70x100/16
7061 QuarkXPress 5. .
912 70x100/16
6844 PDF Adobe Acrobat
384 70x100/16
CAD-.
4753 AutoCAD 2000. ( + CD-ROM )
688 84x108/16
6926 . AutoCAD 2000/2002. .
784 70x100/16
6780 . . AutoCAD 2002. . .
528 70x100/16
6559
944 70x100/16
AvtoCAD 2002 .
6235
Mechanical Desktop 4,5,6.
304 70x100/16
, .
3947 . . 1: High-Performance Networking.
432 60x84/8
3927 . . 2: Networking Essentials
432 84x108/16
6384
736 70x100/16
6843
256 70x100/16
6785
TCP/IP.
576 70x100/16
6893 IP-. , ,
512 70x100/16
1295 . Microsoft BackOffice 2. ( + CD-R
800 60x84/8
6454 ..

Вам также может понравиться