Board index » delphi » ???TTable.Fields[x].Name is empty???

???TTable.Fields[x].Name is empty???

I'm trying to access a field's name by using TTable.Fields[x].Name, but it
ALWAYS returns a null string.  Here is my code:

   oTbl1.DatabaseName := DataPath;
   oTbl1.TableName    := cCurFile;
   oTbl1.Exclusive    := True; {need exclusive use}
   oTbl1.Active       := True;
   ShowMessage('Field Name is ' + oTbl1.Fields[X].Name);

Is there another step I need to follow here?

Thanks,
Jesse

 

Re:???TTable.Fields[x].Name is empty???


Jesse,

Try:

showMessage('Field Name is ' + oTbl1.Fields[2].FieldName);

Quote
Jesse Castleberry wrote in message <6jflrt$et...@forums.borland.com>...
>I'm trying to access a field's name by using TTable.Fields[x].Name, but it
>ALWAYS returns a null string.  Here is my code:

>   oTbl1.DatabaseName := DataPath;
>   oTbl1.TableName    := cCurFile;
>   oTbl1.Exclusive    := True; {need exclusive use}
>   oTbl1.Active       := True;
>   ShowMessage('Field Name is ' + oTbl1.Fields[X].Name);

>Is there another step I need to follow here?

>Thanks,
>Jesse

Re:???TTable.Fields[x].Name is empty???


Quote
> I'm trying to access a field's name by using TTable.Fields[x].Name, but it
> ALWAYS returns a null string.  Here is my code:

>    ShowMessage('Field Name is ' + oTbl1.Fields[X].Name);

Jesse,

TField is a TComponent descendent and all of these have a Name field to name
the component. For the automatically generated field objects of a TDataset
the name is empty. You are after the *FieldName* property, not after Name!

Peter Below (TeamB)  100113.1...@compuserve.com)

Other Threads