PC Review


Reply
Thread Tools Rate Thread

table doesnt have primary key / xsd problem...

 
 
jack
Guest
Posts: n/a
 
      19th Jun 2004
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?


 
Reply With Quote
 
 
 
 
jack
Guest
Posts: n/a
 
      19th Jun 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I have to set the primary key to include primary key fields? boooney Microsoft Access Database Table Design 3 15th Apr 2010 12:17 AM
Data Primary key vs. Artificial (Autonumber) primary key M. Microsoft Access Database Table Design 78 14th Dec 2007 10:10 AM
creating an xsd through xsd designer - xml format Lea mood Microsoft ADO .NET 1 25th Oct 2005 03:50 PM
readxmlschema from .xsd with primary key Ryan Miller Microsoft ADO .NET 1 30th Mar 2004 11:07 PM
Cannot add primary key constraint since primary key is already set for the table Microsoft VB .NET 1 3rd Dec 2003 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:52 PM.