Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

About null value in delphi 6

Posted on 2001-07-04
15
Medium Priority
?
813 Views
Last Modified: 2010-04-06
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'
0
Comment
Question by:Harry_De_Sad
15 Comments
 
LVL 6

Expert Comment

by:edey
ID: 6254234
how about nil?

GL
Mike
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254279
NULL is a C++ equivilant of Object Pascal's nil

Motaz
0
 

Author Comment

by:Harry_De_Sad
ID: 6254292
if write Query1['customer']:=nil; then Delphi send message:
[Error]  Incompatible types
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Expert Comment

by:Motaz
ID: 6254303
Try this:
Query1.FieldByName('customer').Value:= nil;
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254307
Try this:

Query1.FieldByName('customer').Clear;
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254309
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).
0
 

Author Comment

by:Harry_De_Sad
ID: 6254346
if frm_DataModul.temp_ext['contract']<>null
0
 

Author Comment

by:Harry_De_Sad
ID: 6254356
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?
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254366
Try this:

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

Motaz
www.geocities.com/motaz1
0
 

Author Comment

by:Harry_De_Sad
ID: 6254391
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?
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6254412
try the empty quotes

SaveDialog1.filename:='';
Query1['customer']:='';

Mohammed
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254418
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
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6254423
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.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 200 total points
ID: 6254424
Haven't you read what's new in Delphi6? They say they moved a lot of variant stuff out of system.pas and into a new unit named variants.pas. So I guess you only have to add variants to your uses clause and everything will be just fine...

Regards, Madshi.
0
 

Author Comment

by:Harry_De_Sad
ID: 6254629
Madshi you answer the most full and short...
And i don't need any change in my project.
Thank's all.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question