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.

WARNING<br />

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

Be careful that you don’t make bad assumptions about the Bof and Eof<br />

properties. You can’t assume that Bof will be true just because you’re on<br />

the first row of a table. Nor can you assume that Eof will be true when<br />

you’re on the last row of a table. Typically, an additional Prior or Next<br />

is required to set Bof or Eof to true. For example, the sequence First,<br />

Next, Prior won’t reset Bof to true, but First, Next, Prior, Prior will.<br />

Note that Bof is true immediately after open<strong>in</strong>g a table or call<strong>in</strong>g the<br />

First method, and Eof is true immediately after call<strong>in</strong>g the Last<br />

method.<br />

The Append and Insert methods are used to add blank rows to a TDataset. Append adds a<br />

record to the end of the TDataset, whereas Insert adds it at the current cursor position.<br />

Append and Insert both put the TDataset <strong>in</strong> dsEdit mode. The AppendRecord and InsertRecord<br />

methods are used to add non-blank rows to a TDataset us<strong>in</strong>g a supplied set of field values.<br />

The Delete method deletes the row at the current cursor position. The Edit method allows<br />

modification of rows <strong>in</strong> the TDataset, plac<strong>in</strong>g the TDataset <strong>in</strong> dsEdit mode. The Post method<br />

saves these changes to the database, whereas Cancel discards them. This is also true of the<br />

Append and Insert methods—you can Post or Cancel them as well.<br />

Local Filters<br />

The Filter, Filtered, and FilterOptions properties facilitate sett<strong>in</strong>g up local filters on the<br />

TDataset. Local filter<strong>in</strong>g enables you to filter a TDataset from with<strong>in</strong> the application. This can<br />

be advantageous with TDatasets that have a small number of rows; the entirety of the<br />

TDataset will typically be cached by the BDE anyway, so filter<strong>in</strong>g it locally saves <strong>in</strong>teraction<br />

with the database server or network.<br />

Filter enables you to specify a filter expression for restrict<strong>in</strong>g the rows that are visible <strong>in</strong> the<br />

TDataset. The syntax supported <strong>in</strong> the expression is similar to that of a SQL WHERE clause.<br />

Fields can be compared to each other and to static values. The operators shown here can be<br />

used to build your filter expressions:<br />

Operator Use<br />

< Less than<br />

> Greater than<br />

>= Greater than or equal to<br />

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

Saved successfully!

Ooh no, something went wrong!