Harry_De_Sad
asked on
About null value in delphi 6
What happen with NULL value in Delphi6?
in Delphi5 i have code:
SaveDialog1.filename:=null ;
Query1['customer']:=null;
and it's work but in Delphi6 i see:
Undeclared identifier: 'null'
in Delphi5 i have code:
SaveDialog1.filename:=null
Query1['customer']:=null;
and it's work but in Delphi6 i see:
Undeclared identifier: 'null'
NULL is a C++ equivilant of Object Pascal's nil
Motaz
Motaz
ASKER
if write Query1['customer']:=nil; then Delphi send message:
[Error] Incompatible types
[Error] Incompatible types
Try this:
Query1.FieldByName('custom er').Value := nil;
Query1.FieldByName('custom
Try this:
Query1.FieldByName('custom er').Clear ;
Query1.FieldByName('custom
This is from Help, about TField.Clear
Sets the value of the field to NULL.
procedure Clear;
Description
Call the Clear method to give the field a blank value (a NULL value in SQL terms).
Sets the value of the field to NULL.
procedure Clear;
Description
Call the Clear method to give the field a blank value (a NULL value in SQL terms).
ASKER
if frm_DataModul.temp_ext['co ntract']<> null
ASKER
Thank's Motaz Query1.FieldByName('custom er').Clear is work,
but what about this code:
if frm_DataModul.temp_ext['co ntract']<> null then ...
And why null not work?
but what about this code:
if frm_DataModul.temp_ext['co
And why null not work?
ASKER
Thank's Motaz Query1.FieldByName('custom er').Clear is work,
but what about this code:
if frm_DataModul.temp_ext['co ntract']<> null then ...
And why null not work?
but what about this code:
if frm_DataModul.temp_ext['co
And why null not work?
try the empty quotes
SaveDialog1.filename:='';
Query1['customer']:='';
Mohammed
SaveDialog1.filename:='';
Query1['customer']:='';
Mohammed
Hi Mohammed,
SaveDialog1.FileName:= '' is equivilant to := NULL,
because Null string is represented by empty contaitions, but in fields, it is not means Null:
Query1.FieldByName('custom er').AsStr ing:= '' means that it contains an empty string, but the field is not NULL,
Query1.FieldByName('custom er').Clear means clearing data = NULL value
Motaz
SaveDialog1.FileName:= '' is equivilant to := NULL,
because Null string is represented by empty contaitions, but in fields, it is not means Null:
Query1.FieldByName('custom
Query1.FieldByName('custom
Motaz
To clear up some things:
nil <> NULL in Delphi.
nil is a pointer with address $0.
NULL is the NULL of a database field.
In C NULL is the same as nil in Delphi.
So your code is wrong in both Delphi 5 and 6.
Only that Delphi 5 is a bit more tolerant.
SaveDialog1.FileName := nil;
Query1['customer'] := null;
is the correct version.
nil <> NULL in Delphi.
nil is a pointer with address $0.
NULL is the NULL of a database field.
In C NULL is the same as nil in Delphi.
So your code is wrong in both Delphi 5 and 6.
Only that Delphi 5 is a bit more tolerant.
SaveDialog1.FileName := nil;
Query1['customer'] := null;
is the correct version.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Madshi you answer the most full and short...
And i don't need any change in my project.
Thank's all.
And i don't need any change in my project.
Thank's all.
GL
Mike