Link to home
Start Free TrialLog in
Avatar of Harry_De_Sad
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'
Avatar of edey
edey

how about nil?

GL
Mike
NULL is a C++ equivilant of Object Pascal's nil

Motaz
Avatar of Harry_De_Sad

ASKER

if write Query1['customer']:=nil; then Delphi send message:
[Error]  Incompatible types
Try this:
Query1.FieldByName('customer').Value:= nil;
Try this:

Query1.FieldByName('customer').Clear;
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).
if frm_DataModul.temp_ext['contract']<>null
Thank's Motaz Query1.FieldByName('customer').Clear is work,
but what about this code:
if frm_DataModul.temp_ext['contract']<>null then ...

And why null not work?
Try this:

frm_DataModul.temp_ext.FieldByName('contract').IsNull then

Motaz
www.geocities.com/motaz1
Thank's Motaz Query1.FieldByName('customer').Clear is work,
but what about this code:
if frm_DataModul.temp_ext['contract']<>null then ...

And why null not work?
Avatar of Mohammed Nasman
try the empty quotes

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('customer').AsString:= '' means that it contains an empty string, but the field is not NULL,

Query1.FieldByName('customer').Clear means clearing data = NULL value

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.
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Madshi you answer the most full and short...
And i don't need any change in my project.
Thank's all.