Autor Beitrag
HotLaps
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Di 03.09.02 10:25 
Folgendes:

bei einer TTable gibt es ja den "Felder-Editor"
wie kann ich jetzt herausfinfen ob die einzelnen Felder der Tabelle number oder varchar sind?
Steffer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 299



BeitragVerfasst: Di 03.09.02 13:55 
Ich habe das mit einem Array gelöst:
www.faqsen.de/find.j...574850495153495256;2

_________________
Keine Signatur ...
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Di 03.09.02 14:07 
Hallo,

folgender Codeschnipzel schreibt den Feldnamen und Typ in ein zwei Spaltiges tListView (Style=Report):

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
      FOR i := 0 TO Table.FieldDefs.Count -1 DO BEGIN
        NewListItem := FieldList.Items.Add;
        NewListItem.Caption := Table.FieldDefs.Items[i].Name;
        NewListItem.SubItems.Add(Table.FieldDefs.Items[i].FieldClass.ClassName);
        FieldCombo.Items.Add(NewListItem.Caption);
      END;


Gruß
Klabautermann
HotLaps Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Di 03.09.02 15:07 
frmMain.tblItem.Fields[0].DataType

liefert ein TFieldType zurück
nur was mache ich jetzt damit, wie kann ich damit weiter arbeiten
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Di 03.09.02 15:12 
Hi,

poste mal den ganzen Code oder probiere den Codeschnipsel von Klabautermann.
HotLaps Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Di 03.09.02 15:34 
ich lade mit mit
[code]tblItem.GetFieldNames(cbxSpalte.Items);[/code]
die Felder einer Tabelle in eine KomboBox der Anwender wählt dann ein Feld aus und je nachdem dieses Feld ein String oder ein Integer ist soll etwas anderes passieren, sprich der Inhalt eines EditFeldes soll unter Hochkomma gestellt werden oder nicht
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Di 03.09.02 17:13 
HotLaps hat folgendes geschrieben:
frmMain.tblItem.Fields[0].DataType
liefert ein TFieldType zurück
nur was mache ich jetzt damit, wie kann ich damit weiter arbeiten


Wenn du den FieldType hast kannst du doch beliebig drauf reagieren. z.B. in einer CASE Anweisung:

ausblenden Quelltext
1:
2:
3:
4:
CASE frmMain.tblItem.Fields[i].DataType OF
  ftInteger : {Mach was mit Integer}
  ftString : {Mach was mit String}
{...}


Gruß
Klabautermann