📄 ch16.htm
字号:
<TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">UpdatesPending</TD> <TD ALIGN="LEFT">When True, the cached update buffer contains edits not yet applied to the dataset.</TD> </TR></TABLE><H4>TABLE 16.2. PRIMARY TDataSet METHODS.</H4><P><TABLE BORDER="1"> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT"><I>Method</I></TD> <TD ALIGN="LEFT"><I>Description</I></TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Append</TD> <TD ALIGN="LEFT">Creates an empty record and adds it to the end of the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AppendRecord</TD> <TD ALIGN="LEFT">Appends a record to the end of the dataset with the given field data and posts the edit.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">ApplyUpdates</TD> <TD ALIGN="LEFT">Instructs the database to apply any pending cached updates. Updates are not actually written until the CommitUpdates method is called.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Cancel</TD> <TD ALIGN="LEFT">Cancels any edits to the current record if the edits have not yet been posted.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">CancelUpdates</TD> <TD ALIGN="LEFT">Cancels any pending cached updates.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">ClearFields</TD> <TD ALIGN="LEFT">Clears the contents of all fields in the current record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">CommitUpdates</TD> <TD ALIGN="LEFT">Instructs the database to apply updates and clear the cached updates buffer.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Close</TD> <TD ALIGN="LEFT">Closes the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Delete</TD> <TD ALIGN="LEFT">Deletes the current record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">DisableControls</TD> <TD ALIGN="LEFT">Disables input for all data controls associated with the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Edit</TD> <TD ALIGN="LEFT">Enables editing of the current record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">EnableControls</TD> <TD ALIGN="LEFT">Enables input for all data controls associated with the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">FetchAll</TD> <TD ALIGN="LEFT">Gets all records from the cursor to the end of the dataset and stores them locally.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">FieldByName</TD> <TD ALIGN="LEFT">Returns the TField pointer for a field name.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT"> <PRE>FindFirst</PRE> </TD> <TD ALIGN="LEFT"> <PRE>Finds the first record that matches the current filter criteria.</PRE> </TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">FindNext</TD> <TD ALIGN="LEFT">Finds the next record that matches the current filter criteria.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">FindLast</TD> <TD ALIGN="LEFT">Finds the last record that matches the current filter criteria.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">FindPrior</TD> <TD ALIGN="LEFT">Finds the previous record that matches the current filter criteria.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">First</TD> <TD ALIGN="LEFT">Moves the cursor to the first record in the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">FreeBookmark</TD> <TD ALIGN="LEFT">Erases a bookmark set previously with GetBookmark and frees the memory allocated for the bookmark.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">GetBookmark</TD> <TD ALIGN="LEFT">Sets a bookmark at the current record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">GetFieldNames</TD> <TD ALIGN="LEFT">Retrieves a list of the field names in the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">GotoBookmark</TD> <TD ALIGN="LEFT">Places the cursor at the record indicated by the specified bookmark.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Insert</TD> <TD ALIGN="LEFT">Inserts a record and puts the dataset in edit mode.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">InsertRecord</TD> <TD ALIGN="LEFT">Inserts a record in the dataset with the given field data and posts the edit.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Last</TD> <TD ALIGN="LEFT">Positions the cursor on the last record in the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Locate</TD> <TD ALIGN="LEFT">Searches the dataset for a particular record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Lookup</TD> <TD ALIGN="LEFT">Locates a record by the fastest possible means and returns the data contained in the record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">MoveBy</TD> <TD ALIGN="LEFT">Moves the cursor by the specified number of rows.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Next</TD> <TD ALIGN="LEFT">Moves the cursor to the next record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Open</TD> <TD ALIGN="LEFT">Opens the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Post</TD> <TD ALIGN="LEFT">Writes the edited record data to the database or to the cached update buffer.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Prior</TD> <TD ALIGN="LEFT">Moves the cursor to the previous record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Refresh</TD> <TD ALIGN="LEFT">Updates the data in the dataset from the database.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">RevertRecord</TD> <TD ALIGN="LEFT">When cached updates are used, this method discards changes previously made to the record but not yet written to the database.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">SetFields</TD> <TD ALIGN="LEFT">Sets the values for all fields in a record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">UpdateStatus</TD> <TD ALIGN="LEFT">Returns the current update status when cached updates are enabled.</TD> </TR></TABLE><H4>TABLE 16.3. PRIMARY TDataSet EVENTS.</H4><P><TABLE BORDER="1"> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT"><I>Event</I></TD> <TD ALIGN="LEFT"><I>Description</I></TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AfterCancel</TD> <TD ALIGN="LEFT">Generated after edits to a record are canceled.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AfterClose</TD> <TD ALIGN="LEFT">Generated when a dataset is closed.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AfterDelete</TD> <TD ALIGN="LEFT">Generated after a record is deleted from the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AfterEdit</TD> <TD ALIGN="LEFT">Generated after a record is edited.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AfterInsert</TD> <TD ALIGN="LEFT">Generated after a record is inserted.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AfterOpen</TD> <TD ALIGN="LEFT">Generated after the dataset is opened.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AfterPost</TD> <TD ALIGN="LEFT">Generated after the changes to a record are posted.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">BeforeCancel</TD> <TD ALIGN="LEFT">Generated before edits are canceled.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">BeforeClose</TD> <TD ALIGN="LEFT">Generated before a dataset is closed.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">BeforeDelete</TD> <TD ALIGN="LEFT">Generated before a record is deleted.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">BeforeEdit</TD> <TD ALIGN="LEFT">Generated before the dataset goes into edit mode.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">BeforeInsert</TD> <TD ALIGN="LEFT">Generated before a record is inserted.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">BeforeOpen</TD> <TD ALIGN="LEFT">Generated just before a dataset is opened (between the time Active is set to True and the time the dataset is actually opened).</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">BeforePost</TD> <TD ALIGN="LEFT">Generated before edits are posted to the database (or the update cache).</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnCalcFields</TD> <TD ALIGN="LEFT">Generated when calculations are performed on calculated fields.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnDeleteError</TD> <TD ALIGN="LEFT">Generated if an error occurs in deleting a record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnEditError</TD> <TD ALIGN="LEFT">Generated if an error occurs while editing a record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnFilterRecord</TD> <TD ALIGN="LEFT">Generated whenever a new row is accessed and Filter is set to True.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnNewRecord</TD> <TD ALIGN="LEFT">Generated when a new record is added to the dataset.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnPostError</TD> <TD ALIGN="LEFT">Generated when an error occurs while posting the edits to a record.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnUpdateError</TD> <TD ALIGN="LEFT">Generated when an error occurs while cached updates are being written to the database.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OnUpdateRecord</TD> <TD ALIGN="LEFT">Generated when cached updates are applied to a record.</TD> </TR></TABLE><H3><A NAME="Heading12"></A>The Fields Editor</H3><P>Any TDataSet descendant (TTable, TQuery, or TStoredProc) gives access to the FieldsEditor at design time. The Fields Editor enables you to select the fields that youwant to include in the dataset.</P><P>To invoke the Fields Editor, right-click on a Table, Query, or StoredProc componenton your form and choose Fields Editor from the context menu. The Fields Editor isdisplayed. At first the Fields Editor is blank, enabling all fields to be includedin the dataset. You can add as many fields as you want to the dataset by selectingAdd fields from the Fields Editor context menu. You can also create new fields forthe table by choosing New field from the context menu. Figure 16.4 shows the FieldsEditor as it appears after adding fields.</P><P><A HREF="javascript:popUp('28671604.gif')"><B>FIGURE 16.4.</B></A><B> </B><I>TheFields Editor.</I></P><P>After you add fields to the dataset, you can click on any field and modify itsproperties. The properties show up in the Object Inspector, enabling you to changethe display format, constraints, display label, or other field characteristics.</P><P><H4>Cached Updates</H4><PRE>Cached updates enable you to control when edits are applied to a database, and they are controlled by the CachedUpdates property. When cached updates are allowed, changes to records aren't written directly to the database. Instead, the changes are written to an update cache on the local machine. Records are held in the cache until you call the ApplyUpdates method. To abandon any changes in the update cache, you call the CancelUpdates method. You cancel the edits made to the current record by calling the RevertRecord method.</PRE><P>When cached edits are disabled (CachedUpdates is False), any changes made to a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -