FIX: DataSet Containing Attribute Column and Default Value Generates Exception When AllowDBNull Set to False (320881)
The information in this article applies to:
- Microsoft XML Classes (included with the .NET Framework 1.0)
This article was previously published under Q320881 SYMPTOMS When you try to load a DataSet that contains a combination of an attribute column and a default
value, and AllowDBNull is set to false, System.Xml.Schema.Compiler generates an XmlSchemaException exception. For example, if you serialize the following
DataSet to XML
dc = dt.Columns.Add("c2", System.Type.GetType("System.String"));
dc.AllowDBNull = false;
dc.DefaultValue = "Hello";
dc.ColumnMapping = MappingType.Attribute;
the DataSet generates an XML schema that contains the following definition:
<xs:element name="Table1">
<xs:complexType>
<xs:attribute name="c2" type="xs:string" default="Hello" use="required" />
</xs:complexType>
</xs:element>
According to the World Wide Web Consortium (W3C) XML schema
specification, the use attribute must be optional or absent if the default attribute is present. Therefore, the schema that the DataSet generates is not valid. RESOLUTION To work around this problem, either set the column mapping
as an element instead of as an attribute, or do not set the default value.
STATUS This bug was corrected in Microsoft .NET Framework Class
Libraries.
Modification Type: | Major | Last Reviewed: | 9/18/2003 |
---|
Keywords: | kbbug kbpending KB320881 kbAudDeveloper |
---|
|