如何在批处理未更新之前,对dbgrid中待更新的记录逐个检测其合法性

yunfeng138 2004-08-13 03:52:48
各位高手,小弟初学Delphi,在学ADO编程.我用adodataset连接上数据库后,在DBGRID中绑定其数据,然后设置adodataset的打开方式为批事务处理,现在我想实现在提交处理前先自行检测一下各新添记录的合法性,请问各位高手该如何编程,小弟一定结贴,拜托了
...全文
84 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
delphiseabird 2004-08-13
  • 打赏
  • 举报
回复
不用便利,在BeforPost事件中判断,不合法的话报错就行了
liang_z 2004-08-13
  • 打赏
  • 举报
回复
我想我这样写了你应该能做了判断了吧!
liang_z 2004-08-13
  • 打赏
  • 举报
回复
看这个属性:ADOTable1.UpdateStatus
Unit

DB

type
TUpdateStatus = (usUnmodified, usModified, usInserted, usDeleted);

Description

TUpdateStatus is the return type of the UpdateStatus method. UpdateStatus indicates what change, if any, is cached for the current record. TUpdateStatus includes the following values:

Value Description

usUnmodified The current record has no unapplied updates.
usModified The current record has unapplied modifications.
usInserted The current record has been inserted but the insertion was not applied.
usDeleted The current record represents a deleted record, where the deletion has not yet been applied.
yunfeng138 2004-08-13
  • 打赏
  • 举报
回复
小飞,太感激你回贴了,但能否只检测新添记录呢?
IwantFlay 2004-08-13
  • 打赏
  • 举报
回复
adodataset.first;
while not adodataset.eof do
begin
if adodataset.fieldbyName(字段一).AsString<>'1' then
showmessage('字段一不符合条件');
adodataset.next;
end;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧