If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Adabas > problems with null fields when using msaccess with delphi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-03, 02:56
ozwaa ozwaa is offline
Registered User
 
Join Date: Dec 2003
Location: london
Posts: 3
problems with null fields when using msaccess with delphi

i have noticed a problem with null fields when using msaccess or mssqlserver2000 with delphi.I could not believe that this was happening with a product from a reputed company like microsft.
Could anyone advice on how to resolve this problem with delphi?
the error that pops with delphi is a conversion error and the program stops.
i'm surpirsed that nobody has noticed this major problem
thanks
ozwaa
Reply With Quote
  #2 (permalink)  
Old 01-02-04, 21:33
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Normally, whether it is the sql statement or the application interface, you test for null - for example, like isnull...
Reply With Quote
  #3 (permalink)  
Old 01-11-04, 02:06
ozwaa ozwaa is offline
Registered User
 
Join Date: Dec 2003
Location: london
Posts: 3
hi,
Thanks for your reply.. isnull does not work with delphi,its only good with with vb.Mysql and oracle takes care of the null problem when using delphi with them.I need to know about way to tacle this problem of nulls when using access and sqlserver 200 with delphi.
Thanks
edward
my email is edwardfonseca@yahoo.com
Reply With Quote
  #4 (permalink)  
Old 01-11-04, 15:04
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
There is an isnull function within sql server - download books online (the sql server reference for sql server), which you can use within your sql statement.
Reply With Quote
  #5 (permalink)  
Old 08-20-04, 18:03
tgrigsby tgrigsby is offline
Registered User
 
Join Date: Aug 2004
Posts: 10
Read the Manual -- the Delphi manual

I realize this is months later, but for the benefit of anyone else scanning these forums...

Null fields in Access and SQL Server are normal. They represent a lack of data. Sophisticated development environments do *not* hide this fact. The reason you're having a problem is because you're not testing for the a null value. I would imagine you're doing something like

intval := Query1.FieldByName( 'field1' ).AsInteger;

or something similar. If it's possible that your field hasn't been populated yet, it could come back as a null value, in which case you may a conversion problem. What you're really seeing is the field value, which is a variant, attempting to convert a variant null to some other datatype. If you want to familiarize yourself with what's going on behind the scenes, look in the DB.PAS unit of your VCL.

In the meantime, if the value you're testing could contain a null, and that null could throw off your program, test for the null condition using the IsNull property of the TField class. In other words:

if ( not Query1.FieldByName( 'field1' ).IsNull ) then
....

Good luck.

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On