Board index » delphi » >>Table problems<<

>>Table problems<<

I'm having a problem accessing field names at runtime.  If I include the
table fields in the object inspector it is fine,  but I need to access
various tables at different times, so can't have a fixed field list.

I have tried MyTable.GetFieldNames(AFieldList) but that didn't help.

The idea is that required fields in a table will be listed in a second file
or the registry for reference at run-time.  The routine runs through the
table, using a field name, parsing it's value.  Eg:

Begin
  With MyTable Do
  Begin
    Active:=False;
    DatabaseName:=ParamStr(1);
    TableName:=ParamStr(2);
    Active:=True;
    FieldName:=ParamStr(3);
    FieldValue:=ParamStr(4);
    While Not MyTable.Eof Do
    Begin
        If FieldByName(FieldName).AsString=FieldValue Then
        DoSomething
        FindNext
    End;    
    Active:=False;
  End;
End;

If I need to create a TTable object for all the different table types it
would be pointless, and the tables will change structure regularly.

Any ideas would be greatfully appreciated.

Delphi 4 + service pack2

 

Re:>>Table problems<<


On Mon, 16 Nov 1998 15:03:34 GMT, "Ian Howarth"

Quote
<I...@AshLloyd.demon.co.uk> wrote:
>I'm having a problem accessing field names at runtime.  If I include the
>table fields in the object inspector it is fine,  but I need to access
>various tables at different times, so can't have a fixed field list.

>I have tried MyTable.GetFieldNames(AFieldList) but that didn't help.

>The idea is that required fields in a table will be listed in a second file
>or the registry for reference at run-time.  The routine runs through the
>table, using a field name, parsing it's value.  Eg:

The field defenition is stored in the FieldDefs Structure of the Table
or Query (inherits from TDataset).

You can access through FieldDefs.Items to the names. Look to the help,
more is explained there.

Stefan

Other Threads