Unanswered: 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 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.
my email is firstname.lastname@example.org
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
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