第十五章数据访问部件的应用及编程一内容摘要:

re there are aliases defined } := crDefault。 if 1 then MessageDlg( 39。 There are no database aliases currently defined. You 39。 + 39。 need at least one alias to use this demonstration.39。 , mtError, [mbOK], 0 )。 end。 procedure (Sender: TObject)。 var strValue: string。 { Holds the alias selected by the user } bIsLocal: Boolean。 { Indicates whether or not an alias is local } slParams: TStringList。 { Holds the parameters of the selected alias } iCounter: Integer。 { An integer counter variable for loops} begin { Determine the alias name selected by the user } with ListBox1 do strValue := [ItemIndex]。 { Get the names of the tables in the alias and put them in the appropriate list box, making sure the user39。 s choices are reflected in the list. }。 (strValue, { alias to enumerate } 39。 39。 , { pattern to match } 数据集中的数据维护 数据集中的数据维护主要包括数据记录的修改,插入和删除。 Delphi 为数据集部件提供了相应的方法用于其中的数据维护。 这些 方法如表。 表 Delphi 用于数据维护的方法 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 方 法 名 功 能 ────────────────────────────── Edit 将数据集置为编辑状态 ────────────────────────────── Append 投寄所有被修改的记录,将记录指针移到表中的最后 一条记录,且将数据集置为插入状态 ────────────────────────────── Insert 投寄所有被修改的记录将数据集置为插入状态 ────────────────────────────── Post 将插入的新记录和修改的记录写回磁盘上的数据库表, 即投寄,当投寄成功时数据集回到浏览状态,若投寄 不成功数据集仍然保持原有状态 ────────────────────────────── Cancel 取消当前的操作且将数据集置为浏览状态 ────────────────────────────── Delete 删除当前记录指针所在的记录且将数据集置为浏览状态 ─────────────── ─────────────── AppendRecord 在表的最后插入一条新记录,记录的各个字段值作为 AppendRecord 的参数传递给新记录 ────────────────────────────── InsertRecord 在当前指针所在记录的后面插入一条新记录, 记录的 各个字段值作为 InsertRecord 的参数传递给新记录。 ────────────────────────────── SetRecords 修改当前记录,字段名和相应的字段值作为 SetRecords 的参数 ━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━ Edt 方法:如果应用程序想对数据集中的数据记录进行修改,我们必须要将数据集设置成编辑状态。 调用数据集部件的 Edit 方法便可以将数据集置成编辑状态,当数据集已经处在编辑状态时,调用 Edit 方法不会产生作用。 当数据集处于编辑状态时,移动记录指针或调用 post 方法都可以将当前记录的修改写回到磁盘数。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。