如伴水所说, 如果DataSet是Active的并且RecorCount>0 则一定有记录被选中, 如果有多条记录被选中, 则请使用DBGrid1.SelectedRows 如下: with myDBGrid do begin if SelectedRows.Count>0 then with DataSource.DataSet do for i:=0 to SelectedRows.Count-1 do begin myConnect.BeginTrans; try GotoBook(pointer(SelectedRows.Items[i])); if not DoOneRecordAuditing(AuditingFlag) then//一个自定义的函数,你不必关心 begin myConnect.RollbackTrans; exit; end; myConnect.CommitTrans; except myConnect.RollbackTrans; exit; end; end; end;
如果DataSet是Active的并且RecorCount>0
则一定有记录被选中,
如果有多条记录被选中,
则请使用DBGrid1.SelectedRows
如下:
with myDBGrid do
begin
if SelectedRows.Count>0 then
with DataSource.DataSet do
for i:=0 to SelectedRows.Count-1 do
begin
myConnect.BeginTrans;
try
GotoBook(pointer(SelectedRows.Items[i]));
if not DoOneRecordAuditing(AuditingFlag) then//一个自定义的函数,你不必关心
begin
myConnect.RollbackTrans;
exit;
end;
myConnect.CommitTrans;
except
myConnect.RollbackTrans;
exit;
end;
end;
end;
为什么我用
DBGrid1.DataSource.DataSet.RecordCount <> 0
不用
DBGrid1.DataSource.DataSet.RecordCount > 0 //?????????