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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TIP<br />

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

You can drag TFields from the Fields Editor directly onto a form. This<br />

will create a data-aware control and a correspond<strong>in</strong>g label on the form.<br />

You can configure which data-aware component is dropped onto the<br />

form us<strong>in</strong>g the TControlClass property <strong>in</strong> the Database Explorer.<br />

TFields also support implicit data conversions. That is, you don’t have to know what type<br />

of data a TField actually stores to convert it to another data type. This is facilitated by TField’s<br />

Value property. Value is a variant type that is implicitly converted when it is assigned or<br />

receives a value. For example, you can assign a str<strong>in</strong>g to a boolean field us<strong>in</strong>g its Value variant,<br />

like so:<br />

TBooleanField MyBoolean;<br />

...<br />

MyBoolean->Value=”T”;<br />

You can also assign a numeric field to a str<strong>in</strong>g control us<strong>in</strong>g its Value property:<br />

TCurrencyField MyMoney;<br />

...<br />

Edit1->Text=MyMoney->Value;<br />

TField’s amaz<strong>in</strong>g ability to implicitly convert between different data types makes it<br />

chameleon-like <strong>in</strong> its capacity to adapt to vary<strong>in</strong>g data requirements. This simplifies your<br />

applications and makes for less work when an application’s underly<strong>in</strong>g data structure<br />

changes.<br />

Summary<br />

As you can see, the <strong>C++</strong>Builder database class hierarchy is rich, yet easy to use. Great attention<br />

has been given to mak<strong>in</strong>g the hierarchy not only extensive, but also coherent. The VCL<br />

database classes strike a good balance between functionality and ease of use.<br />

Workshop<br />

The Workshop conta<strong>in</strong>s quiz questions to help you solidify your understand<strong>in</strong>g of the<br />

material covered and exercises to provide you with experience <strong>in</strong> us<strong>in</strong>g what you have learned.<br />

You can f<strong>in</strong>d answers to the quiz questions <strong>in</strong> Appendix A, “Answers to Quiz Questions.”<br />

471<br />

12

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

Saved successfully!

Ooh no, something went wrong!