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. MP3 编码解码 附完整c代码

    近期一直不间断学习音频处理,一直也没想着要去碰音频编解码相关. 主要是觉得没什么实际的作用和意义. 不管视频编解码,图像编解码,音频编解码,都有很多组织基金在推动. 当然,在一些特定的情景下,需要用起 ...

  2. golang 多维哈希(map,hashmap)实践随笔

    有些场景使用多维哈希来存储数据,时间复杂度恒定,简单粗暴好用.这里记录一下. 如下是三维哈希的简单示意图,建议层数不要太多,否则时间久了,自己写的代码都不认识. 下图是三维哈希在内存的存储形式,has ...

  3. 蓝桥杯 算法训练 K好数

    参考:https://blog.csdn.net/jjmjeffrey/article/details/69298110 https://www.cnblogs.com/TWS-YIFEI/p/634 ...

  4. DevExpress TreeList用法总结

    http://blog.itpub.net/29251214/viewspace-774395/ http://blog.csdn.net/czp_huster/article/details/501 ...

  5. 创龙DSP6748开发板上电测试-第一篇

    1. 创龙DSP6748开发板测试.2980元的售价很高,我估计新的1200元比较合适,当然创龙定价是按照供需关系的.仿真器XDS100V2卖598元,真是狮子大张口. 2. 上电是5V-2A的电源. ...

  6. 浅析Win8/8.1下安装SQL Server 2005 出现服务项无法正常启动解决方案

    如何才能在微软最新的Windows8/Windows 8.1下正常使用SQL Server 2005套件呢?下面就简单介绍利用文件替换法,解决其服务项无法正常启动的临时方案.当然还是建议使用SQL S ...

  7. jQuery实现“回到顶部”按钮功能

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. <cfloat> (float.h)

    头文件: <cfloat> (float.h) 浮点类型的特性 这个头文件为特殊系统和编译器的实现描述了浮点类型的特征. 一个浮点数包含四个元素: 一个标志(a sign):正或负; 一个 ...

  9. Oracle作业练习题

    第一问 //登陆scott用户 //解锁 alter user scott account unlock; //给用户申请密码 alter user scott identified by tiger ...

  10. 《Git学习指南》学习笔记(一)

    第二章 入门 git的安装 在Linux下,git的安装很简单.以我的系统Deepin/Ubuntu为例,只需在终端敲入sudo apt-get install git即可.其他Linux发行版可尝试 ...