Delphi-PRAXiS
Seite 2 von 4     12 34      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi Couldn't convert varient of type (NULL) into type (String) (https://www.delphipraxis.net/92033-couldnt-convert-varient-type-null-into-type-string.html)

mkinzler 13. Mai 2007 18:02

Re: Couldn't convert varient of type (NULL) into type (Strin
 
Delphi-Quellcode:
if not Query2.FieldValues['WER'].isNull then ... else ...

Svenkan 13. Mai 2007 18:30

Re: Couldn't convert varient of type (NULL) into type (Strin
 
Ich hab das jetzt so gemacht:

Delphi-Quellcode:
hcode2:='<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+if not Query2.FieldValues['WER'].isNull then Query2.FieldValues['WER'] else empty+'</font></td>';
Aber entweder bin ich zu blöd zu kapieren, wie das funktioniert oder es klappt so wirklich nicht..
Zitat:

[Error] Unit2.pas(228): Statement expected, but expression of type 'String' found

mkinzler 13. Mai 2007 18:41

Re: Couldn't convert varient of type (NULL) into type (Strin
 
So geht es natürlich nicht.

Delphi-Quellcode:
function CheckNull( Field: TField; eValue: Variant):Variant;
begin
    if not Field.isNull then result := Field.Value else result := eValue;
end;
...
hcode:='<tr>'+sLineBreak+'<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('KLASSEN'], 'empty'))+...

Svenkan 13. Mai 2007 18:51

Re: Couldn't convert varient of type (NULL) into type (Strin
 
Danke soweit schonmal!
Bin irgendwie immer noch nicht so ganz ausm PHP-Konzept raus..
Leider bekomme ich den gleichen fehler mit dem NULL-Dingens immer noch..:(
Ich habe alles nach deinem Schema umgebaut.

Delphi-Quellcode:
   hcode:='<tr>'+sLineBreak+'<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('KLASSEN'), 'empty')+'</font></td>'+sLineBreak+'<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('S'), 'empty')+'</font></td>'+sLineBreak+'<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('FUER'), 'empty')+'</font></td>'+sLineBreak;
   WriteLn(Datei, hcode);
   hcode2:='<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('WER'), 'empty')+'</font></td>'+sLineBreak+'<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('FACH'), 'empty')+'</font></td>'+sLineBreak+'<td width=9% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('RAUM'), 'empty')+'</font></td>'+sLineBreak+'<td width=37% bgcolor=#666666><font color=#FFFFFF size=2 face=Arial> '+CheckNull(Query2.FieldByName('BEMER_SCH'), 'empty')+'</font></td>'+sLineBreak+'</tr>';
   WriteLn(Datei, hcode2);
Das erste Feld, welches leer (also nil) ist, wäre 'WER'. Und genau in der Zeile befindet sich dann auch wieder der Ausgabefehler.

mkinzler 13. Mai 2007 19:08

Re: Couldn't convert varient of type (NULL) into type (Strin
 
Hast du mal im Debugger geschaut, wo dieser Fehler auftritt?

Svenkan 13. Mai 2007 19:09

Re: Couldn't convert varient of type (NULL) into type (Strin
 
In der Zeile wo hcode2 geschrieben werden sollte.

mkinzler 13. Mai 2007 19:10

Re: Couldn't convert varient of type (NULL) into type (Strin
 
In meiner Funktion

Svenkan 13. Mai 2007 19:14

Re: Couldn't convert varient of type (NULL) into type (Strin
 
Es ist genau die gleiche Stelle, wie vor dem Einbau deiner Funktion.

mkinzler 13. Mai 2007 19:20

Re: Couldn't convert varient of type (NULL) into type (Strin
 
Nein schau dir mal der Ablauf in der Funktion an.

Svenkan 13. Mai 2007 19:23

Re: Couldn't convert varient of type (NULL) into type (Strin
 
Sry wenn ich jetzt so blöd frage, aber..
wo gennau? :D
Da gibts ziemlich viele Debugwindows..


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:45 Uhr.
Seite 2 von 4     12 34      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz