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?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Leon Shaw

    Get Primary Key

    Leon Shaw, Jul 18, 2003, in forum: Microsoft ASP .NET
    Replies:
    3
    Views:
    276
    Kevin Spencer
    Jul 21, 2003
  2. Maury

    From .xsd to table creation

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

    VS-generated XSD DataSets and Relationships problem

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

    ObjectDataSource and Primary Key on DB Table

    Guest, Apr 13, 2006, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    245
    Guest
    Apr 13, 2006
  5. Guest

    ObjectDataSource and Primary Key on DB Table

    Guest, Apr 19, 2006, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    553
    Guest
    Apr 19, 2006
  6. Juan T. Llibre
    Replies:
    15
    Views:
    735
    mocoder
    Dec 20, 2006
  7. GaryDean

    Problem with .xsd datasets

    GaryDean, May 12, 2007, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    754
    Walter Wang [MSFT]
    May 17, 2007
  8. Bobby Edward

    Annoying XSD problem

    Bobby Edward, Jan 30, 2009, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    189
    Bobby Edward
    Jan 30, 2009
Loading...