Autor Beitrag
darksign
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 58



BeitragVerfasst: Mo 30.04.07 15:13 
Hallo! Ich habe mehrere Integer-Variablen, und diese werden in eine DB gespeichert! Ich will aber, falls diese Variablen keinen Wert haben, in die entsprechenden Felder der Datenbank "NULL" reinschreiben! Wie kann ich also den integer-Variablen diesen Wert zuweisen?


mfg
DnC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 98

XP
Delphi 3,6,7,2005 PE
BeitragVerfasst: Mo 30.04.07 15:18 
ich hab keine Ahnung von Datenbanken, aber bei nem Integer ohne Wert würde ich einfach mal 0 eintragen... oder ne Zahl die nicht vorkommen kann
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 30.04.07 15:20 
Eine (Delphi-)Integer-Variablen kannst du kein NULL zuweisen.

_________________
Markus Kinzler.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 30.04.07 15:20 
Moin!

Das geht nicht. ;) "NULL" steht ja für einen Wert, der nicht im Wertebereich des Feldes vorkommt, eben "nicht vorhanden". Du darfst also das Feld nicht beschreiben, damit es den Wert "NULL" hat. :idea: Man kann sicher diesen Wert auch manuell in das Feld schreiben; wie weiß ich aber auch nicht. :? ;)

cu
Narses

//EDIT: zulangsam... :(

_________________
There are 10 types of people - those who understand binary and those who don´t.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mo 30.04.07 15:23 
Wenn du wirklich den Wert NULL in eine Variable speichern willst, musst du wohl ein Variant nehmen...

_________________
Bravery calls my name in the sound of the wind in the night...
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 30.04.07 15:25 
Hier nur noch ergänzend für das Leeren des Feldes (mit NULL versehen):

ausblenden Delphi-Quelltext
1:
Dataset.FieldByName('MeinFeld').Clear;					


Man kann anstelle von Integervariablen Varianten nehmen, diese sind jedoch recht performancelastig.

Cu,
Udontknow
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 30.04.07 15:27 
Moin!

Ach ja, .Clear... :autsch: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mo 30.04.07 15:27 
.clear funktioniert aber auc nur, wenn man mit nem TDataset arbeitet, nicht aber zwingend, wenn man z.B. eine update-Query mit einem NULL-Paramter füllen will, dann kommts wieder auf die DB-Komponenten an.

Nur zur Vollständigkeit :)

_________________
Bravery calls my name in the sound of the wind in the night...