Subject | Iterating Fields in IBO Dataset |
---|---|
Author | Ross C.Williams |
Post date | 2003-03-30T15:32Z |
How do you iterate through fields (columns?) in a dataset?
I want to test whether a field with a particular name exists in the
dataset. With the BDE I would do this by something like:
function FieldExists(DataSet: TDataSet; const Field: string): Boolean;
var
i: integer;
begin
result := False;
for i := 0 to (DataSet.fieldDefs.count - 1) do
begin
if DataSet.FieldDefs.Items[i].Name = Field then
begin
result := True;
break; //ends iteration since named field was found
end
else
begin
Result := dsFieldExists(DataSet, Field);
// Calculated or Lookup field exists
end;
end;
end;
I want to test whether a field with a particular name exists in the
dataset. With the BDE I would do this by something like:
function FieldExists(DataSet: TDataSet; const Field: string): Boolean;
var
i: integer;
begin
result := False;
for i := 0 to (DataSet.fieldDefs.count - 1) do
begin
if DataSet.FieldDefs.Items[i].Name = Field then
begin
result := True;
break; //ends iteration since named field was found
end
else
begin
Result := dsFieldExists(DataSet, Field);
// Calculated or Lookup field exists
end;
end;
end;