Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Internet/XML/Data Binding    [ Add a report in this area ]  
Report #:  2434   Status: Open
If Node doesn't exist in XML and data binding was generated with type other than string for that node you reciee an error when trying to access it
Project:  Delphi Build #:  6.240
Version:    6.0 Submitted By:   Wayne Sepega
Report Type:  Basic functionality failure Date Reported:  9/21/2002 5:13:31 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   209522
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (3 Total Ratings)
4.33 out of 5
Total Votes: 2
Description
---------------------------
Databindingbug
---------------------------
Could not convert variant of type (Null) into type (Boolean)
---------------------------
OK  
---------------------------


I've not tried this in Delphi 7 yet as I don't have it.

I know I can trap the error but that would imply doing try/except every time that you access a property for the interface that was generated by the data bidning wizard.

Where this affected me is I have an app where I use XML to store the user settings. I was working out the XML for and had it finished and deployed the app. Well I made enhancements to the app and added new user settings. When I went to deploy the new application those settings were not there and when trying to be read I got the above error.


What I propose as a fix is for the data binding to check if the current Node is NULL before assigning the resul for the getProperty and make it return an apporiate result. Much like TField.AsString/AsIntegr/AsBoolean/etc... does.

This is currently what I'm doing for my app but I have to redo it everytime I decided I need to regen the data binding code.

Also just a note, when importing an TypeLib there is a BIG warning that the code was auto generated and any changes you did manually will/could be over written. I don't see one of those types of warnings for the Data Binding.

Please see the attached application example.
Steps to Reproduce:
None
Workarounds
None
Attachment
DataBinding Bug.zip
Comments

Eric Brown at 9/22/2002 1:14:29 PM -
I verified that this bug still exists with the Delphi 7 databinding wizard.

Eric Brown at 3/10/2003 7:50:28 AM -
The more I use XML and the databinding wizard the more frustrated I am becoming with this bug.  And it really upsets me that this issue was posted quite a long time ago and it still remains as "Reported" rather than "Open".  This tells me Borland isn't even looking at this issue.

Get with the program guys, I understand you're busy, but these kinds of bugs shouldn't be here in the first place!!!!  NULL values are NOT against W3C standards and it's perfectly valid.

The problem lies in this:

  Result := ChildNodes['selected'].NodeValue;

The error is:

Could not convert variant of type (Null) into type (Boolean)

Because of this, code like so doesn't work:

if VarIsNull(Facility.Selected) then

GRRRR!!!!!! PLEASE FIX THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Eric Brown at 3/10/2003 8:34:14 AM -
BTW a workaround is as follows:

  if VarIsNull(ChildNodes['selected'].NodeValue) then
    Result := False
  else
    Result := ChildNodes['selected'].NodeValue;


I'd really like to see the databinding wizard automatically generate that code for me..  And perhaps asking me what the default value should be.  (True or False).

Server Response from: ETNACODE01