table doesnt have primary key / xsd problem...

Discussion in 'Microsoft ASP .NET' started by jack, Jun 19, 2004.

  1. jack

    jack Guest

    using the following xsd code :

    <xs:element name="tblUsers">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="UserID" type="xs:int" />
    <xs:element name="FullName" type="xs:string" />
    <xs:element name="UserName" type="xs:string" />
    <xs:element name="Password" type="xs:string" />
    <xs:element name="Email" type="xs:string" />
    </xs:sequence>
    </xs:complexType>
    <xs:unique name="tblUsersKey1" msdata:primaryKey="true">
    <xs:selector xpath="." />
    <xs:field xpath="mstns:UserID" />
    </xs:unique>
    </xs:element>

    i'm unable to execute this against a dataset loaded with the schema and a
    sample xml data file.

    theRow = systemDB.Tables["tblUsers"].Rows.Find(theUser.UserID);

    Exception Details: System.Data.MissingPrimaryKeyException: Table doesn't
    have a primary key.

    what am i missing?
     
    jack, Jun 19, 2004
    #1
    1. Advertisements

  2. jack

    jack Guest

    after a good bit of searching, i found one way to deal with it.

    systemDB = new DataSet();
    systemDB.ReadXmlSchema("db.xsd");
    systemDB.ReadXml("db.xml");
    x[0] = systemDB.Tables["tblUsers"].Columns["UserID"];
    systemDB.Tables["tblUsers"].PrimaryKey = x;

    this accomplishes the goal... But to avoid having to hard portions of the
    schema into the app I need to find a way of embedding the PK within the xsd
    file. Any suggestions?

    "jack" <> wrote in message
    news:...
    > using the following xsd code :
    >
    > <xs:element name="tblUsers">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="UserID" type="xs:int" />
    > <xs:element name="FullName" type="xs:string" />
    > <xs:element name="UserName" type="xs:string" />
    > <xs:element name="Password" type="xs:string" />
    > <xs:element name="Email" type="xs:string" />
    > </xs:sequence>
    > </xs:complexType>
    > <xs:unique name="tblUsersKey1" msdata:primaryKey="true">
    > <xs:selector xpath="." />
    > <xs:field xpath="mstns:UserID" />
    > </xs:unique>
    > </xs:element>
    >
    > i'm unable to execute this against a dataset loaded with the schema and a
    > sample xml data file.
    >
    > theRow = systemDB.Tables["tblUsers"].Rows.Find(theUser.UserID);
    >
    > Exception Details: System.Data.MissingPrimaryKeyException: Table doesn't
    > have a primary key.
    >
    > what am i missing?
    >
    >
     
    jack, Jun 19, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maury

    From .xsd to table creation

    Maury, Jul 4, 2005, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    156
    Maury
    Jul 4, 2005
  2. Danny Tuppeny

    VS-generated XSD DataSets and Relationships problem

    Danny Tuppeny, Mar 2, 2006, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    133
    Danny Tuppeny
    Mar 2, 2006
  3. Guest

    ObjectDataSource and Primary Key on DB Table

    Guest, Apr 13, 2006, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    155
    Guest
    Apr 13, 2006
  4. Guest

    ObjectDataSource and Primary Key on DB Table

    Guest, Apr 19, 2006, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    173
    Guest
    Apr 19, 2006
  5. GaryDean

    Problem with .xsd datasets

    GaryDean, May 12, 2007, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    372
    Walter Wang [MSFT]
    May 17, 2007
Loading...

Share This Page