Microsoft Knowledge Base Email Alertz

KBAlertz.com: When you attempt to read an Extensible Markup Language (XML) schema into a

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 316820 - Last Review: March 10, 2006 - Revision: 3.2

FIX: Cannot derive and extend a column in XSD with DataSet

This article was previously published under Q316820
This article refers to the following Microsoft .NET Framework Class Library namespace:
  • System.Data

On This Page

SYMPTOMS

When you try to read an Extensible Markup Language (XML) schema into a DataSet, the following duplicate name exception may be thrown when the XML Schema Definition language (XSD) derives and extends a column definition:
An unhandled exception of type 'System.Data.DuplicateNameException' occurred in system.data.dll

Additional information: A column named 'column1' already belongs to this DataTable.
If you handle this exception within a try/catch block, you receive the following error message:
System.Data.DuplicateNameException: A column named 'column1' already belongs to this DataTable.

CAUSE

The DataSet is treating the column derivation and extension as if it were the definition of an entirely new column, with the same name as an existing column.

RESOLUTION

To avoid this exception, define a new element type with the attributes that you want, instead of deriving from and extending an existing element type.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section. This bug was corrected in Microsoft ADO.NET (included with the .NET Framework 1.1), and Microsoft Visual Studio .NET 2003, Professional Edition.

MORE INFORMATION

Steps to reproduce the behavior

  1. Create a new XSD file named Test.xsd. Paste the following code into it:
    <?xml version="1.0" standalone="yes"?>
    <xsd:schema id="MyDataSet" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    
     <xsd:complexType name="columns" abstract="true"> 
       <xsd:sequence>
          <xsd:element name="column1" type="xsd:string"/>
       </xsd:sequence>
     </xsd:complexType>
    
     <xsd:element name="table1"> 
      <xsd:complexType> 
       <xsd:complexContent>
        <xsd:extension base="columns">
          <xsd:sequence>
           <xsd:element name="column1" msdata:ReadOnly="True" type="xsd:string"/>
          </xsd:sequence>
        </xsd:extension>
       </xsd:complexContent>
      </xsd:complexType>
     </xsd:element>
    
    </xsd:schema>
    						
  2. Create a new Visual Basic .NET console application.
  3. Paste the following code into the sub Main of Module1:
    Dim ds As New DataSet()
    ds.ReadXmlSchema("C:\Test.xsd") 'Exception thrown here.
    Console.Write("Schema Loaded Successfuly")
    Console.Read()
    					
  4. Change the string that is being passed in the call to ReadXML to reflect the path to the XML file that you created.
  5. Press F5 to run and compile the application. You receive the error message listed in the "Symptoms" section.
  6. In order to avoid this exception being thrown, replace code in the XSD file with the following code that defines a new element with the attributes that you want, instead of deriving from an existing element:
    <?xml version="1.0" standalone="yes" ?>
    <xsd:schema id="MyDataSet" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
     <xsd:element name="table1">
      <xsd:complexType>
       <xsd:sequence>
        <xsd:element name="column1" type="xsd:string" msdata:ReadOnly="True" />
       </xsd:sequence>
      </xsd:complexType>
     </xsd:element>
    </xsd:schema>
  7. Press F5 to run and compile the application. Output to the console confirms that the XSD schema was loaded successfully. Press ENTER to stop the running application, and then close the Console window.

REFERENCES

For more information about XML integration with ADO.NET, click the following article number to view the article in the Microsoft Knowledge Base:
313649  (http://kbalertz.com/Feedback.aspx?kbNumber=313649/ ) Roadmap for XML integration with ADO.NET
For more information about XML schemas in the .NET Framework, click the following article number to view the article in the Microsoft Knowledge Base:
313826  (http://kbalertz.com/Feedback.aspx?kbNumber=313826/ ) Roadmap for XML schemas in the .NET Framework

APPLIES TO
  • Microsoft ADO.NET (included with the .NET Framework)
  • Microsoft Visual Studio .NET 2002 Professional Edition
Keywords: 
kbbug kbfix kbnofix kbsystemdata kbinterop kbvs2002sp1sweep KB316820
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Martin Report As Irrelevant  
Written: 7/25/2006 6:20 AM
This bug was definitly NOT corrected!!!!!!!!!!!!!!

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please