Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass True/False value to a bound Windows Check Box

XML Web Services How To

How to pass True/False value to a bound Windows Check Box

by  paulray  Posted    (Edited  )
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
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top