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.

434 Day 12<br />

Each component narrative consists of three sections:<br />

■ A description of the component, its module, and class ancestor, as well as tables<br />

list<strong>in</strong>g its key properties, methods, and events<br />

■ A key elements section<br />

■ A tasks section<br />

The key properties, methods, and events tables are by no means exhaustive—see the<br />

<strong>C++</strong>Builder documentation, or, better yet, the VCL source code, for complete lists of these.<br />

The idea is to give you a thorough baptism <strong>in</strong>to the <strong>C++</strong>Builder database architecture without<br />

ventur<strong>in</strong>g <strong>in</strong>to every nook and cranny of the VCL.<br />

TSession<br />

Module: DB Class ancestor: Tcomponent<br />

Because <strong>C++</strong>Builder automatically creates a TSession component for you each time your<br />

application runs, you won’t normally need to create one yourself. This built-<strong>in</strong> TSession can<br />

be referenced us<strong>in</strong>g <strong>C++</strong>Builder’s global Session variable.<br />

As a rule, you won’t need more than one TSession per application. The only exception to this<br />

is when you’re build<strong>in</strong>g multithreaded database applications. When do<strong>in</strong>g that, you may<br />

need to use TSession components to open extra connections <strong>in</strong>to your server <strong>in</strong> order to keep<br />

database access <strong>in</strong> one thread from <strong>in</strong>terfer<strong>in</strong>g with that <strong>in</strong> another. You can drop as many<br />

TSession components as you need onto a form or data module and then utilize them <strong>in</strong> your<br />

Database and TDataset components. In a multithreaded database application, you typically<br />

set up one TSession per thread. Note that <strong>C++</strong>Builder def<strong>in</strong>es another global variable,<br />

Sessions, for track<strong>in</strong>g multiple Session components <strong>in</strong> a s<strong>in</strong>gle application. Sessions is of<br />

type TSessionList and conta<strong>in</strong>s an entry for each Session component <strong>in</strong> the application.<br />

Table 12.2 lists the key properties, Table 12.3 lists the key methods, and Table 12.4 lists the<br />

key events for TSession.<br />

Table 12.2. TSession key properties.<br />

Property Description<br />

DatabaseCount Returns a count of the number of active TDatabases.<br />

Databases Returns the array of active TDatabases.<br />

Handle Provides access to the BDE handle—used for direct BDE calls.<br />

KeepConnections Determ<strong>in</strong>es whether <strong>in</strong>active connects are reta<strong>in</strong>ed.

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

Saved successfully!

Ooh no, something went wrong!