navigatingtablesandqueries.htm
来自「Absolute Database 5.12 src. Absolute Da」· HTM 代码 · 共 162 行
HTM
162 行
<html>
<head>
<title>Navigating Tables and Queries</title>
</head>
<!--#include virtual="/inc/header.php"-->
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#FFFFFF">
<tr>
<td align="left">
<span style="font-family:Helvetica,Arial; font-size:12pt; color:#000000"><b>Navigating Tables and Queries
<br>
</b></span>
</td>
<td align="right">
<font face="Arial" size="2">
<a href="usingparametersinqueries.htm">Previous</a>
<a href="overview.htm">Top</a>
<a href="usingdatacontrols.htm">Next</a>
</font>
</td>
</tr>
</table>
<br><br>
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
Each active dataset (table or query) has a <i>cursor</i>, or pointer, to the current row in the dataset. The current row in a dataset is the one whose field values currently show in single-field, data-aware controls on a form, such as TDBEdit, TDBLabel, and TDBMemo. If the dataset supports editing, the current record contains the values that can be manipulated by edit, insert, and delete methods.
<br>
<br>
You can change the current row by moving the cursor to point at a different row. The following table lists methods you can use in application code to move to different records:
<br>
<br>
<table border="0" cellpadding="1"><tr><td align="left" valign="top" width="101">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><b><u>Method</u></b>
<br>
</span></td><td align="left" valign="top" width="344">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><b><u>Moves the cursor to</u></b>
<br>
</span></td></tr><tr><td align="left" valign="top" width="101">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_first.htm>First</a>
<br>
</span></td><td align="left" valign="top" width="344">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The first row in a dataset.
<br>
</span></td></tr><tr><td align="left" valign="top" width="101">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_last.htm>Last</a>
<br>
</span></td><td align="left" valign="top" width="344">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The last row in a dataset.
<br>
</span></td></tr><tr><td align="left" valign="top" width="101">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_next.htm>Next</a>
<br>
</span></td><td align="left" valign="top" width="344">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The next row in a dataset.
<br>
</span></td></tr><tr><td align="left" valign="top" width="101">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_prior.htm>Prior</a>
<br>
</span></td><td align="left" valign="top" width="344">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The previous row in a dataset.
<br>
</span></td></tr><tr><td align="left" valign="top" width="101">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_moveby.htm>MoveBy</a>
<br>
</span></td><td align="left" valign="top" width="344">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">A specified number of rows forward or back in a dataset.
<br>
</span></td></tr></table>
<br>
<br>
TDataSet also defines three properties that provide useful information when iterating through the records in a dataset.
<br>
<br>
<table border="0" cellpadding="1"><tr><td align="left" valign="top" width="136">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><b><u>Property</u></b>
<br>
</span></td><td align="left" valign="top" width="343">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><b><u>Description</u></b>
<br>
</span></td></tr><tr><td align="left" valign="top" width="136">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_bof.htm>Bof</a> (Beginning-of-file)
<br>
</span></td><td align="left" valign="top" width="343">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">True: the cursor is at the first row in the dataset.False: the cursor is not known to be at the first row in the dataset
<br>
</span></td></tr><tr><td align="left" valign="top" width="136">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_eof.htm>Eof</a> (End-of-file)
<br>
</span></td><td align="left" valign="top" width="343">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">True: the cursor is at the last row in the dataset.False: the cursor is not known to be at the first row in the dataset
<br>
</span></td></tr><tr><td align="left" valign="top" width="136">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><a href=tdataset_recno.htm>RecNo</a><span style="font-family:MS Sans Serif; font-size:8pt; color:#000000">
<br>
</span></span></td><td align="left" valign="top" width="343">
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">Indicates the active record in the dataset.
<br>
</span></td></tr></table>
<br>
<br>
The following code illustrates one way you might code a record-processing loop for a table called ABSTable1:<b>
<br>
<br>
Example:
<br>
<br>
</b><span style="font-family:Courier New; font-size:8pt; color:#000000">AbsTable1.DisableControls;
<br>
<br>
<b>try</b>
<br>
AbsTable1.First; <span style="font-family:Courier New; font-size:8pt; color:#000080"><i>{ Go to first record, which sets Eof False }</i></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">
<br>
<b>while</b> <b>not</b> AbsTable1.Eof <b>do</b> <span style="font-family:Courier New; font-size:8pt; color:#000080"><i>{ Cycle until Eof is True }</i></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">
<br>
<b>begin</b>
<br>
<span style="font-family:Courier New; font-size:8pt; color:#000080"><i>{ Process each record here }</i></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">
<br>
...
<br>
AbsTable1.Next; <span style="font-family:Courier New; font-size:8pt; color:#000080"><i>{ Eof False on success; Eof True when Next fails on last record }</i></span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">
<br>
<b>end</b>;
<br>
<b>finally</b>
<br>
AbsTable1.EnableControls;
<br>
<b>end</b>;
<br>
</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><b>
<br>
Tip: </b>This example also shows how to disable and enable data-aware visual controls tied to a dataset. If you disable visual controls during dataset iteration, it speeds processing because your application does not need to update the contents of the controls as the current record changes. After iteration is complete, controls should be enabled again to update them with values for the new current row. Note that enabling of the visual controls takes place in the finally clause of a <b>try</b>...<b>finally</b> statement. This guarantees that even if an exception terminates loop processing prematurely, controls are not left disabled.
<br>
<br>
<br>
<br>
<br>
</span></span>
<!--#include virtual="/inc/footer.php"-->
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?