TField.CurValue Property

Represents the current value of the field component including changes made by other users of the database

Description

Use CurValue to examine the value of a field when a problem occurs while posting a value to the database using a provider. If the current field value causes a problem, such as a key violation, when posting the value, an event is generated to allow applications to respond to the problem. Provider components generate an OnUpdateError event. If a provider returns problem records to the client dataset, the client dataset generates an OnReconcileError event. In the OnUpdateError or OnReconcileError event handler, NewValue is the unposted value that caused the problem, OldValue is the value that was originally assigned to the field before any edits were made, and CurValue is the value that is currently assigned to the field. CurValue may differ from OldValue if another user changed the value of the field after OldValue was read.

Note: CurValue is only supported when the dataset is a TClientDataSet. In the provider's OnUpdateError event, a temporary client dataset containing fields with a CurValue property is passed to the event handler.

TField.NewValue Property

Represents the current value of the field component including pending cached updates.

Description

Use NewValue to examine or change the current value of a field when in the process of applying multiple updates. If the current field value is causing a problem, such as a key violation, when applying updates, datasets generate an OnUpdateError event. Similarly, provider components generate an OnUpdateError event when problems occur posting records from a client, and client datasets generate an OnReconcileError event when informed of problems by the provider. In the event handler, assign a new value to NewValue to correct the problem.

NewValue is the same as Value, except when errors are encountered while posting records. Setting NewValue in an OnUpdateError event handler, an OnUpdateRecord event handler, or an OnReconcileError event handler causes NewValue to differ from Value until the records have finished being applied to the underlying database table.

Note: The NewValue property is only usable when the data is accessed using a TClientDataSet component or cached updates is enabled

TField.OldValue Property

Represents the original value of the field (as a Variant).

Description

Read the OldValue property to examine or retrieve the original value of the field that was obtained from the dataset before any edits were posted. For example, in Delphi the following line replaces current pending changes with a field's original value:

Copy Code

NewValue :=OldValue;

Once records are applied successfully to the database, the old field value cannot be retrieved.

Note: the OldValue property is only usable when the data is accessed using a TClientDataSet component or cached updates is enabled

TField.Value Property

Represents the data in a field component.

Description

Use Value to read data directly from and write data directly to a field component at runtime. For example, use the Value property to affect the contents of a field that is not Visible.

Delphi Examples:

Copy Code

{

This example uses a button to copy the value of a field in

the previous record into the corresponding field in the

current record.

}

procedure TForm1.Button1Click(Sender: TObject);

var

SavePlace: TBookmark;

PrevValue: Variant;

begin

with Customers do

begin

{ get a bookmark so that we can return to the same record }

SavePlace := GetBookmark;

try

{ move to prior record}

FindPrior;

{ get the value }

PrevValue := FindField('Field2').Value;

{Move back to the bookmark

this may not be the next record anymore

if something else is changing the dataset asynchronously }

GotoBookmark(SavePlace);

{ Set the value }

Edit;

FindField('Field2').Value := PrevValue;

{ Free the bookmark }

finally

FreeBookmark(SavePlace);

end;

end;

end;

{

To ensure that the button is disabled when there is no

previous record, the OnDataChange event of the DataSource

detects when the user moves to the beginning of file (BOF

property becomes true), and disables the button.  Detection

occurs on scrolling and editing, not selection with the mouse.

}

procedure TForm1.DS2DataChange(Sender: TObject; Field: TField);

begin

if Customers.Bof then

Button1.Enabled := False

else

Button1.Enabled := True;

end;

---------------------

Delphi Dataset CurValue的更多相关文章

  1. DataSnap 多层返回数据集分析FireDAC JSON

    采用服务器返回数据,一种是返回字符串数据例如JSON,跨平台跨语言,任何语言调用都支持兼容,类似WEBService. 第二种是紧密结合c++builder语言,传输DataSet,可以是Client ...

  2. delphi中 dataset容易出错的地方

    最近写delphi项目,用到的数据集中的dataset,一直修改exception啊,写下过程. 在对数据集进行任何操作之前,首先要打开数据集.要打开数据集,可以把Active属性设为True,例如: ...

  3. Delphi 获取DataSet传入参数后的SQL命令

    ClientDataSet1.CommandText := sSQL;   ClientDataSet1.Params.Clear; ClientDataSet1.CommandText :='SEL ...

  4. Delphi 变体数组 Dataset Locate 查找定位

    Format 函数 Delphi 支持“开参数”和动态数组,变体数组,使用时的语法类似 Delphi 中的集合:采用两个方括号把不同类型的变量括起来(这太方便了啊),也可以采用声明一个 TVarRec ...

  5. delphi手动创建dataset并插入值

    unit Unit1; interface uses  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Syste ...

  6. Delphi中DataSet和JSON的互转

    //1)数据集转换为JSON字符串://需USES System.JSON; function DataSetToJson(ADataset: TDataSet): string; // [{&quo ...

  7. delphi 中出现dataset not in edit or insert mode的问题

    self.ADOQuery2.Edit;self.ADOQuery2.First;while not self.ADOQuery2.Eof dobeginself.ADOQuery2.FieldByN ...

  8. delphi中json转dataset

    unit uJSONDB; interface uses SysUtils, Classes, Variants, DB, DBClient, SuperObject, Dialogs; type T ...

  9. Delphi:ClientDataset+TDataSetProvider的数据保存问题

    看到一篇介绍ClientDataSet和TDataSetProvider,非常精彩,特此保存. ==================================================== ...

随机推荐

  1. (数据科学学习手札37)ggplot2基本绘图语法介绍

    一.简介 ggplot2是R语言中四大著名绘图框架之一,且因为其极高的参数设置自由度和图像的美学感,即使其绘图速度不是很快,但丝毫不影响其成为R中最受欢迎的绘图框架:ggplot2的作者是现任Rstu ...

  2. React Router 4.0 实现路由守卫

    在使用 Vue 或者 Angular 的时候,框架提供了路由守卫功能,用来在进入某个路有前进行一些校验工作,如果校验失败,就跳转到 404 或者登陆页面,比如 Vue 中的 beforeEnter 函 ...

  3. 优步UBER司机全国各地奖励政策汇总 (2月29日-3月6日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  4. MySQL 存储过程常用SQL语句收集

    1,select curdate() /*2016-10-08*/ 2,select date_sub(curdate(), INTERVAL 6 DAY) /*2016-10-02*/ 3,case ...

  5. 无偏方差为什么除以n-1

    设样本均值为,样本方差为,总体均值为,总体方差为,那么样本方差有如下公式:. 很多人可能都会有疑问,为什么要除以n-1,而不是n,但是翻阅资料,发现很多都是交代到,如果除以n,对样本方差的估计不是无偏 ...

  6. 阅读笔记《JavaScript语言精粹》

    阅读笔记<JavaScript语言精粹> 对象 1.检索属性 使用[]和. 2.引用传递 JavaScript的简单数据类型包括数字.字符串.布尔值.null值和undefined值.其它 ...

  7. facebook原生广告添加adchoice图标

    1.在需要显示adchoice的地方添加一个textview: <LinearLayout android:id="@+id/ad_ic_action" android:la ...

  8. java 浅复制 深复制

    1.浅复制 只是复制引用,对引用的操作会影响之前复制的对象. 2.深复制 复制一个完全独立的对象,复制对象与被复制对象相互之间不影响. 只是概念性东西....

  9. List和Turple

    List 格式:classmates = ['Michael', 'Bob', 'Tracy'] 读取list长度用:len(classmetes) 索引:索引正向从0开始,逆向从-1开始 在末尾增加 ...

  10. CentOS 7.2使用tomcat部署jenkins2.130

    一.jenkins介绍 Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,无论用的是什么平台.这是一个免费的源代码,可以处理任何类型的构建或持续集成.集成Jenkins可以用于一些测 ...