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.

438 Day 12<br />

Table 12.6. TDatabase key methods.<br />

Method Function<br />

Open Explicitly opens a database connection.<br />

Close Explicitly close a database connection.<br />

Table 12.7. TDatabase key events.<br />

Event Catalyst<br />

OnLog<strong>in</strong> Occurs when a SQL TDatabase is opened and Log<strong>in</strong>Prompt is true.<br />

Key Elements<br />

You use the DatabaseName property to def<strong>in</strong>e an application-specific, or local, BDE alias.<br />

Once you’ve specified a name here (it can be the same as the component’s Name property, if<br />

you like), you’ll see it “published” <strong>in</strong> the drop-down DatabaseName property list of TDataset<br />

components like TTable and TQuery. You can then select it from those lists to l<strong>in</strong>k the<br />

associated TDataset component with your Tdatabase.<br />

AliasName specifies the BDE alias you want this TDatabase to use. It refers to an alias you’ve<br />

already def<strong>in</strong>ed us<strong>in</strong>g the BDE Configuration utility and uses it to get default sett<strong>in</strong>gs. Note<br />

that this property and the DriverName property are mutually exclusive. Sett<strong>in</strong>g one automatically<br />

clears the other.<br />

If you elect not to set AliasName, use the DriverName property to identify a BDE driver that<br />

you want to use <strong>in</strong>stead. This can <strong>in</strong>clude the STANDARD driver for local tables (dBASE<br />

and Paradox), or the INTERBASE, SYBASE, ORACLE, or MSSQL drivers for SQL<br />

database servers. As mentioned previously, the DriverName property and the AliasName<br />

property are mutually exclusive.<br />

Toggl<strong>in</strong>g the Connected property opens and closes the database connection. You can set it to<br />

true <strong>in</strong> the <strong>C++</strong>Builder Object Inspector to open a database connection while you’re<br />

design<strong>in</strong>g. If you open a TDataset that refers to your TDatabase, the TDatabase will<br />

automatically be opened. If you close a TDatabase that has associated TDatasets, you’ll close<br />

them as well.<br />

TIP<br />

Note that if you def<strong>in</strong>e an application-specific alias, the form or data<br />

module that conta<strong>in</strong>s the associated TDatabase must be currently loaded<br />

<strong>in</strong> order for you to open TDatasets that reference it.

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

Saved successfully!

Ooh no, something went wrong!