Delphi Dataset CurValue
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的更多相关文章
- DataSnap 多层返回数据集分析FireDAC JSON
采用服务器返回数据,一种是返回字符串数据例如JSON,跨平台跨语言,任何语言调用都支持兼容,类似WEBService. 第二种是紧密结合c++builder语言,传输DataSet,可以是Client ...
- delphi中 dataset容易出错的地方
最近写delphi项目,用到的数据集中的dataset,一直修改exception啊,写下过程. 在对数据集进行任何操作之前,首先要打开数据集.要打开数据集,可以把Active属性设为True,例如: ...
- Delphi 获取DataSet传入参数后的SQL命令
ClientDataSet1.CommandText := sSQL; ClientDataSet1.Params.Clear; ClientDataSet1.CommandText :='SEL ...
- Delphi 变体数组 Dataset Locate 查找定位
Format 函数 Delphi 支持“开参数”和动态数组,变体数组,使用时的语法类似 Delphi 中的集合:采用两个方括号把不同类型的变量括起来(这太方便了啊),也可以采用声明一个 TVarRec ...
- delphi手动创建dataset并插入值
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Syste ...
- Delphi中DataSet和JSON的互转
//1)数据集转换为JSON字符串://需USES System.JSON; function DataSetToJson(ADataset: TDataSet): string; // [{&quo ...
- delphi 中出现dataset not in edit or insert mode的问题
self.ADOQuery2.Edit;self.ADOQuery2.First;while not self.ADOQuery2.Eof dobeginself.ADOQuery2.FieldByN ...
- delphi中json转dataset
unit uJSONDB; interface uses SysUtils, Classes, Variants, DB, DBClient, SuperObject, Dialogs; type T ...
- Delphi:ClientDataset+TDataSetProvider的数据保存问题
看到一篇介绍ClientDataSet和TDataSetProvider,非常精彩,特此保存. ==================================================== ...
随机推荐
- GeekOS: 一、构建基于Ubuntu9.04的实验环境
参考:http://www.cnblogs.com/wuchang/archive/2009/05/05/1450311.html 补充:在最后步骤中,执行bochs即可弹出运行窗口
- JavaWeb——升级赛-学生成绩管理系统(1)jsp---19.01.03
add.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pa ...
- java常见类
- BZOJ1303_中位数图_KEY
题目传送门 较水,开两个桶即可. 题目可以理解为,将大于B的数看为1,小于B的数看为-1,将以B这个数为中位数的序列左右分为两半,加起来为0. code: #include <cstdio> ...
- 滑雪_KEY
滑雪 ( skiing.pas/c/cpp) [题目描述] MM 参加一个滑雪比赛,滑雪场是一个 N×M 的矩形, MM 要从起点( 1, 1)滑到( N,M).矩形中每个单位格子有一个海拔高度值 h ...
- iOS 库 开发小结
1.基本用法 定义类,导出头文件,注意头文件,库文件的search path 2.加载资源 - 使用主工程的文件,耦合性太强 - 封装到NSBundle中 NSBundle可以封装xib storyb ...
- jQuery个人总结
选择 1. end()的使用 $('div') .find('h3') .eq(2) .html('Hello') .end() //退回到选中所有的h3元素的那一步 .eq(0) //选中第一个h3 ...
- 【原创】linux命令-Axel命令 - linux多线程下载 - 费元星 - 未来星开发团队
[费元星版权Q:9715234] Axel 是 Linux 下一个不错的HTTP/FTP高速下载工具.支持多线程下载.断点续[费元星版权Q:9715234]传,且可以从多个地址或者从一个地址的多个连接 ...
- MySQL日期函数、时间函数总结(MySQL 5.X)
一.获得当前日期时间函数 1.1 获得当前日期+时间(date + time)函数:now() select now(); # :: 除了 now() 函数能获得当前的日期时间外,MySQL 中还有下 ...
- 谁说接口不能有代码?—— Kotlin接口简介(KAD 26)
作者:Antonio Leiva 时间:Jun 6, 2017 原文链接:https://antonioleiva.com/interfaces-kotlin/ 与Java相比,Kotlin接口允许你 ...