There appears to be a problem in passing Boolean values to a Windows Form Checkbox when accessing data via XML Web Services. Note: This problem has been tested with MS-SQL 2000 but not other db's. When you generate a dataset in your web services, VB.NET creates the .xsd for you. In the case of a bit (boolean) value, DBNull is passed, not the table default (usually 0 or false). To overide this behaviour, you must update the .xsd to show a default value.
For example.
The IDE generated .xsd provides the following fields for a table we will call tblSystemMode
...
<xs:sequence>
<xs:element name="Mode_ID" type="xs:string" />
<xs:element name="Description" type="xs:string" />
<xs:element name="SYS_REC" type="xs:boolean" />
</xs:sequence>
...
You must change the boolean field (SYS_REC) to include a default value to over-ride the DBNull value that will be passed in the above example:
...
<xs:sequence>
<xs:element name="Mode_ID" type="xs:string" />
<xs:element name="Description" type="xs:string" />
<xs:element name="SYS_REC" type="xs:boolean" default="0" />
</xs:sequence>
...
If you don't default the boolean value, the web services will pass DBNull, and unless the user clicks the checkbox, the DBNull value will be passed back, ( and potentialy fail if Allow Nulls is set to false.
...
Hope this helps you in your VB.NET travels!
Paul
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.