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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with schema-based Dataset

Status
Not open for further replies.

DaedalusPrime

Programmer
May 25, 2005
13
US
My application uses a dataset that Visual Studio generated using an XML schema. When I try to load the form that has textboxes bound to the various data elements I get an exception thrown that reads:

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll

Additional information: Cannot add primary key constraint since primary key is already set for the table.


Since my schema contains a large number of elements, I've pasted below a small example I found that follows the same structural format that my schema does:

Code:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
  <xs:element name="book">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="title" type="xs:string"/>
        <xs:element name="author" type="xs:string"/>
        <xs:element name="character" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="name" type="xs:string"/>
              <xs:element name="since" type="xs:date"/>
              <xs:element name="qualification" type="xs:string"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

I'm not sure where the multiple keys are being defined or how to enforce that only one is in such a way that Visual Studio won't complain.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top