各位高手,小弟初学Delphi,在学ADO编程.我用adodataset连接上数据库后,在DBGRID中绑定其数据,然后设置adodataset的打开方式为批事务处理,现在我想实现在提交处理前先自行检测一下各新添记录的合法性,请问各位高手该如何编程,小弟一定结贴,拜托了

解决方案 »

  1.   

    adodataset.first;
    while not adodataset.eof do
    begin
      if adodataset.fieldbyName(字段一).AsString<>'1' then
         showmessage('字段一不符合条件');
      adodataset.next;
    end;
      

  2.   

    看这个属性:ADOTable1.UpdateStatus
    UnitDBtype
      TUpdateStatus = (usUnmodified, usModified, usInserted, usDeleted);DescriptionTUpdateStatus 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 DescriptionusUnmodified 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.
      

  3.   

    不用便利,在BeforPost事件中判断,不合法的话报错就行了