12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C++</strong>Builder Database Architecture<br />

■ You do not need the TQuery or TStoredProc components unless you’re writ<strong>in</strong>g your<br />

own SQL or access<strong>in</strong>g server-based stored procedures. You can open database tables<br />

<strong>in</strong> any of the local or remote formats supported by <strong>C++</strong>Builder us<strong>in</strong>g just the<br />

TTable component.<br />

■ You’ll normally use the TTable component to send/receive data from databases. As<br />

mentioned, TTable is the centerpiece of <strong>C++</strong>Builder’s database access. You use it to<br />

reference database tables and to exchange data with data-aware controls.<br />

■ The components on the Data Controls page are visual, data-aware controls—they<br />

allow data to be displayed and allow users to change the data visually. They’re “data<br />

smart” versions of the controls you often see <strong>in</strong> W<strong>in</strong>dows applications. You’ll use<br />

these components to build the user <strong>in</strong>terface of database applications. They <strong>in</strong>teract<br />

with data access controls such as TTable to provide users with database access.<br />

■ TDataset descendants (for example, TTable, TQuery, and TStoredProc) retrieve data<br />

from databases, but they cannot supply this data directly to data-aware components<br />

(such as TDBEdit); they need TDatasource to function as the conduit between them<br />

and your application’s data-aware controls. This means that data-aware components<br />

such as TDBEdit do not refer directly to the TDataset that provides their data<br />

access. Instead, they reference a TDatasource that, <strong>in</strong> turn, references a TDataset.<br />

■ So, to build a simple data-aware form you need three th<strong>in</strong>gs: a TTable, a<br />

TDatasource, and whatever data-aware controls the form requires (TDBEdit,<br />

TDBMemo, and so on).<br />

A Tour of the <strong>C++</strong>Builder Database<br />

Components<br />

Now that you’ve received a basic overview of the <strong>C++</strong>Builder database architecture, let’s cover<br />

the components <strong>in</strong>dividually. I’ll go through <strong>C++</strong>Builder’s database components one by one<br />

and discuss the key elements of each. I’ll build on the general discussion of the database<br />

architecture by giv<strong>in</strong>g you a thorough tour of the <strong>C++</strong>Builder database components that<br />

encompass it.<br />

I’ve <strong>in</strong>tentionally omitted components that act only as support classes. If a class is not actually<br />

a component—that is, if it’s merely an ancestor of a component—I don’t <strong>in</strong>clude it. This<br />

<strong>in</strong>cludes the TDataset and TDBDataSet classes, for example. They’re class ancestors of the<br />

TTable, TQuery, and TStoredProc components. My emphasis here is on components that you<br />

can manipulate us<strong>in</strong>g <strong>C++</strong>Builder’s visual tools. Although the ancestor class hierarchy is<br />

important, most of the properties, events, and methods you’ll need to be aware of are<br />

provided <strong>in</strong> <strong>C++</strong>Builder’s components by design.<br />

433<br />

12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!