Autor Beitrag
Whisper
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

WIN XP
Delphi
BeitragVerfasst: Mi 28.09.05 11:42 
Moderiert von user profile iconraziel: Abgetrennt diesem Topic.

Vielen Dank! Hat mir sehr weitergeholfen!

Hier noch ein Problem:

ausblenden Delphi-Quelltext
1:
2:
a := dm.TableMaschinen.FieldValues['b']; -> //ist ein feld aus der db, das zahlen aufnimmt aber auch leer sein kann
if (a is Null) or (a = ' 'then



[Fehler:] Unit1.pas(264): "Operator ist auf diesen Operandentyp nicht anwendbar"

:roll:

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 28.09.05 12:20 
Hallo!

Die Variable "a" ist wohl vom Typ String, und diese wiederum kann nicht den Wert Null haben bzw. mit ihm verglichen werden. Enthält das angegebene Feld den Wert NULL, wird bei einer Zuweisung zu a eine implizite Umwandlung zu String vorgenommen, aus NULL wird ''. Es reicht also, einfach auf "a=''" zu prüfen.

Cu,
Udontknow
Whisper Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

WIN XP
Delphi
BeitragVerfasst: Mi 28.09.05 13:43 
user profile iconUdontknow hat folgendes geschrieben:
Hallo!

Die Variable "a" ist wohl vom Typ String, und diese wiederum kann nicht den Wert Null haben bzw. mit ihm verglichen werden. Enthält das angegebene Feld den Wert NULL, wird bei einer Zuweisung zu a eine implizite Umwandlung zu String vorgenommen, aus NULL wird ''. Es reicht also, einfach auf "a=''" zu prüfen.

Cu,
Udontknow


sorry, hatte vergessen zu schreiben, dass a vom typ integer ist!

:wink:
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 28.09.05 14:48 
Da erfolgt dann eine implizite Konvertierung nach 0. Da du dann natürlich nicht mehr unterscheiden kannst, ob wirklich 0 oder etwa NULL im Feld stand, solltest du besser einfach das Feld direkt prüfen:

ausblenden Delphi-Quelltext
1:
if (dm.TableMaschinen.FieldByName('B').IsNull) ...					


Cu,
Udontknow
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mi 28.09.05 15:06 
Normalerweise deutet eine Fehlermeldung wie 'Unit1.pas (264)' auf einen COMPILER-Fehler hin.
Die Zeile ist eine da drunter
ausblenden Delphi-Quelltext
1:
if (a is Null) or (a = ' 'then					

Wenn a ein Integer ist, dann kann Delphi das nicht kompilieren.

_________________
Na denn, dann. Bis dann, denn.
Whisper Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

WIN XP
Delphi
BeitragVerfasst: Mi 28.09.05 15:15 
user profile iconUdontknow hat folgendes geschrieben:
Da erfolgt dann eine implizite Konvertierung nach 0. Da du dann natürlich nicht mehr unterscheiden kannst, ob wirklich 0 oder etwa NULL im Feld stand, solltest du besser einfach das Feld direkt prüfen:

ausblenden Delphi-Quelltext
1:
if (dm.TableMaschinen.FieldByName('B').IsNull) ...					


Cu,
Udontknow


@Udontknow:
VIELEN DANK!!!!
Genau da war das Problem, welches jetzt nicht mehr existiert!!! *hihihihi*

:lol: