hallo bianca!
neben der eigenschaft 'FieldName' verfügt TField auch noch über die eigenschaften
'DataType'. dort findest du die verschiedenen feldtypen der einzelnen tabellenfelder abgelegt.
um allerdings die feldlänge zu ermitteln, hab ich die eigenschaft 'FieldDefs' verwendet. mit ihrer hilfe ist es mir dann gelungen
nachdem ein beispiel mehr als 1000 worte sagt -->
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46:
| procedure TReparaturDlg.ShowTabInfo(aFilename: TFilename); var old_tbl: TTable; i, aRow: ShortInt; mFeldType: TFieldType; begin old_tbl:= TTable.Create(nil); try with old_tbl do begin Databasename:= ExtractFilePath(aFilename); Tablename := ExtractFilename(aFilename); end;
old_tbl.Open; GridDeleteGrid(Grid1);
for i:= 0 to pred(old_tbl.FieldDefs.Count do begin GridAppendRow(Grid1); aRow:= i+1; Grid1.Cells[0,aRow]:= IntToStr(aRow); Grid1.Cells[1,aRow]:= old_tbl.FieldDefs[i].Name;
mFeldType:= old_tbl.FieldDefs[i].DataType; case mFeldType of ftString: Grid1.Cells[2,aRow]:= 'String'; ftSmallInt: Grid1.Cells[2,aRow]:= 'SmallInt'; ftInteger: Grid1.Cells[2,aRow]:= 'Integer'; ftFloat: Grid1.Cells[2,aRow]:= 'Float'; ftDate: Grid1.Cells[2,aRow]:= 'Date'; ftTime: Grid1.Cells[2,aRow]:= 'Time'; ftDateTime: Grid1.Cells[2,aRow]:= 'DateTime'; ftBoolean: Grid1.Cells[2,aRow]:= 'Boolean'; ftAutoInc: Grid1.Cells[2,aRow]:= 'AutoInc' end;
Grid1.Cells[3,aRow]:= IntToStr(old_tbl.FieldDefs[i].Size); Grid1.Cells[4,aRow]:= IntToStr(old_tbl.FieldDefs[i].Precision) end;
old_tbl.Close; GridDeleteRow(Grid1,Grid1.Row); Grid1.Row:= 1 finally old_tbl.Free end; end; |
mfg, stefan