Autor Beitrag
patmann2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Di 31.08.04 20:46 
Hallo

Ich habe eine Tabelle (TTable) Datenbanktyp ist ttParadox.
Einige der Spalten habe ich so deklariert, das sie nicht notwedig sind. Also z.B.
ausblenden Quelltext
1:
Tabelle.Add('Username',ftString,50,false);					

Ich kann jetzt sehr einfach mit den Befehl
ausblenden Quelltext
1:
Tabelle.FieldVariants['Username']:=edit1.text;					

den Inhalt eines Editfeldes in eine Spalte schreiben. Wenn ich jedoch das ganze zurückbekommen möchte mit
ausblenden Quelltext
1:
edit1.text:=Tabelle.FieldVariants['Username'];					

und der Inhalt des Fields ist leer bekomme ich die Fehlermeldung Variantumwandlung nicht möglich. Wie kann ich feststellen ob mein Variant leer ist? Mit
If Tabelle.FieldVariants['Username']='' then ...
geht es nicht, der Variant enthält wohl eine Information und mit
ausblenden Quelltext
1:
If Tabelle.FieldVariants['Username'] = NIL then ...					

geht es auch nicht, das ist eine ungültige Zuweisung.
Kann mir einer helfen?

Danke Patmann
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 31.08.04 20:57 
patmann2001 hat folgendes geschrieben:
Wie kann ich feststellen ob mein Variant leer ist?

Wenn du eine Variable vom Typ Variant hast, dann kannst du das varEmpty prüfen. Schau mal in der OH unter VarTyp.
Da müsstest du eigentlich was zum Thema finden.

_________________
Ciao, Sprint.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 31.08.04 21:05 
Oder aber:
ausblenden Delphi-Quelltext
1:
function VarIsNull(const V: Variant): Boolean;					

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 31.08.04 21:11 
Ich nutze immer folgende Variante:

ausblenden Delphi-Quelltext
1:
edit1.text:=Tabelle.FieldByName('Username').AsString;					


Wenn der Feldwert NULL ist, so wird automatisch als String '' geliefert.

Cu,
Udontknow