Autor Beitrag
daggit
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Mo 13.06.05 12:25 
Hi,

ich mochte einer Variablen eine Datenbankspalte zuweisen. Klappt auch. Meine Variable ist vom Typ String, meine Spalte in der Datenbank vom Typ VarChar(40). Nun kann es aber vorkommen das die Spalte NULL ist. Wenn Delphi nun versucht den NULL wert meiner variablen zuzuweisen, tritt ein fehler auf.
Weiss jemand welchen Variablentyp ich hier nehmen müsste?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 13.06.05 12:29 
Zeig mal den Source.
Normalerweise sollte es so gehen:
ausblenden Delphi-Quelltext
1:
deineStringVariable := query1.FieldByName(<DeinSpaltenName>).AsString;					

Zumindest hatte ich damit bisher keine Probleme. Auch nicht bei <Null>.
daggit Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Mo 13.06.05 12:34 
ah ok klappt :) ich hatte nicht "AsString" sondern "Value" verwendet. Aber micht wundert dennoch das folgendes nicht funktioniert:

meineStringVariable := NULL;
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 13.06.05 13:33 
Null ist ein Wert aus der Datenbank. Bedeutet nichts anderes, als dass der Feldinhalt unbestimmt ist.
Ansonsten gibt es Null nicht in Delphi (iirc).
Ein leerer String ist eben nicht Null, sondern = ''.
Becks16
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Mo 13.06.05 13:35 
kann man sowas nicht auch abfangen mit einer ShowMessage('Feld A ist leer machen sie da was rein') @ jasucol ?????

mfg

_________________
Ich bin Dumm und weiss nichts :-)
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 13.06.05 13:40 
Natürlich geht das. Da das aber nicht gefragt wurde und absolut einfach ist, schreibe ich jetzt nicht, wie es geht.
Becks16
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Mo 13.06.05 13:42 
das brauchst du auch nicht zu schreiben das weiss ich selbst falls das eine anspielung sein solle :-))))

_________________
Ich bin Dumm und weiss nichts :-)
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 13.06.05 14:43 
Titel: Null-Frage
Da du die Frage an mich gerichtet hast und fragst, ob das geht, muss ich davon ausgehen, dass du es nicht weißt.
Ansonsten ist deine Frage nicht sinnvoll gewesen.
Becks16
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 405



BeitragVerfasst: Mo 13.06.05 14:44 
ich fande sie schon sinnvoll denn es gibt mehrere wege die nach rom führen...

mfg

_________________
Ich bin Dumm und weiss nichts :-)