Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

About null value in delphi 6

Posted on 2001-07-04
15
Medium Priority
?
787 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

719 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