Other unnecessary primary leys are added to my dataset

L

lennert.acke

Hi,

I defined an XML Schema and got a DataSet out of it. In the Schema,
there were primary keys and relations defined and displayed correctly
in VS.NET.

However, I noticed that .NET disregards the primary keys and adds it's
own as well. It does not enforce uniqueness on the primary keys I
defined, nor does it respects the relationships defined on them.

Instead it adds it's own primary keys in the form of 'DataTableName_Id'
and uses that to build the relation.

My data requires the use of my own primary keys. How can I tell .NET to
use mine ??

Any help appreciated.
 
L

lennert.acke

OK, I think I understand all of this better now, but I still don't have
a correct solution.

I have two not-nested complexType's: company and product. In company as
well as in product there exists a field called "ID". I defined a
primary key on this element in the company element like this:

<xsd:key name="companyKey1" msdata:primaryKey="true">
<xsd:selector xpath="." />
<xsd:field xpath="mstns:ID" />
</xsd:key>

I then added a foreign key to couple companies and products. In the
company element I defined:

<xsd:keyref name="companyproduct" refer="companyKey1"
msdata:IsNested="true">
<xsd:selector xpath=".//mstns:product" />
<xsd:field xpath="mstns:ID" />
</xsd:keyref>

I've played around all afternoon with all different options (nested /
not nested - implicit / explicit) bu I still don't have the solution:
coupling between companies and products in a datagrid.

By accident I sometimes stumbled upon a coupling between the data, but
never in a way i found correct (for example, unnested XML output ...)

Thank you in advance for your help.
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Top