all groups > dotnet datatools > december 2004 >
You're in the

dotnet datatools

group:

Primary Key not returning in dataset


Primary Key not returning in dataset JRLander
12/30/2004 3:05:07 PM
dotnet datatools: I am populating a dataset with a simple SQL statement, I need to have the
primary keys returned with the data. I am using the following code to get
the data and the keys:

dataAdapter.MissingSchemaAction = missingSchemaAction.AddWithKey
dataAdapter.Fill(ds)

When I use the following SQL statement, I do not get any primary keys
returned in the dataset:

SELECT table1.* FROM table1 INNER JOIN table2 ON table1.ID = table2.ID

However, if I use the following statement, I get keys returned.

SELECT * FROM table1 INNER JOIN table2 ON table1.ID = table2.ID

If I do this, I get the keys for both tables returned as a primary key.
Why, in my first SQL Statement do I not get any primary keys, and is there a
way to work around that?

Thanks,

Re: Primary Key not returning in dataset Sylvain Lafontaine
12/30/2004 8:51:25 PM
Yes: populate the first table, then the second. ADO.NET was not designed to
work with flattened queries.

S. L.

[quoted text, click to view]

AddThis Social Bookmark Button