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. [NOIP2017]列队(树状数组)

    定义第i行为所有的点(i,j),0<j<m 可以发现,每一行是相对独立的,每一次操作只会影响到当前行和最后一列 考虑每一行和最后一列各开一个树状数组,但这样显然会爆空间 实际上,对于没有离 ...

  2. 网络流Edmonds-Karp算法入门

    今天自习课没事干,看书自学了一下网络流中的EK算法.(求最大流) 设s为源点,t为汇点,C为容量矩阵,F为流量矩阵,f为最大流量. 1.初始化F,f 2.用BFS在残量网络中找到一条从s到t的最短增广 ...

  3. GDAL中GDALDataset::RasterIO分块读取的实现

    GDALDataset类中的RasterIO函数能够对图像任意指定区域.任意波段的数据按指定数据类型.指定排列方式读入内存和写入文件中,因此可以实现对大影像的分块读.写运算操作.针对特大的影像图像,有 ...

  4. How To Install Apache Tomcat 7 on CentOS 7 via Yum

    摘自:https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-centos-7-via-y ...

  5. C#监听锁屏代码

    今天,偶然间在技术群看有人问,怎么监听锁屏. 在此处记录一下 public class Constrctor { public Constrctor() { SystemEvents.SessionS ...

  6. Vs2015 遇到 CL:fatal error c1510 cannot load language clui.dll

    网上说什么点击修复VS,修改VS的,经验证都不好使,直接下载这个库,放在system32/64下面皆可以了

  7. Unity制作人物头像小图标和小地图

    人物头像的制作: 在场景中添加人物模型和环境模型 设置人物的layer为Player 在主摄像机的基础上,新建一个次摄像机并将摄像机镜头对准人物面部,调整至合适大小. 设置次摄像机 culling m ...

  8. JavaScript --经典问题

    JavaScript中如何检测一个变量是一个String类型?请写出函数实现 方法1. function isString(obj){ return typeof(obj) === "str ...

  9. Java基础知识:Java实现Map集合二级联动3

    * Returns an image stored in the file at the specified path * @param path String The path to the ima ...

  10. adb 常用命令及操作

    获取序列号: adb get-serialno 查看连接计算机的设备: adb devices 重启机器: adb reboot 重启到bootloader,即刷机模式: adb reboot boo ...