Primary Key not returning in dataset - DOTNET

This is a discussion on Primary Key not returning in dataset - DOTNET ; 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 ...

+ Reply to Thread
Results 1 to 2 of 2

Primary Key not returning in dataset

  1. Default Primary Key not returning in dataset

    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,

    Jason Lander

  2. Default Re: Primary Key not returning in dataset

    Yes: populate the first table, then the second. ADO.NET was not designed to
    work with flattened queries.

    S. L.

    "JRLander" <JRLander@discussions.microsoft.com> wrote in message
    news876FE70-37C8-4401-8E7C-DA43272D51CB@microsoft.com...
    >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,
    >
    > Jason Lander




+ Reply to Thread

Similar Threads

  1. Can't get XSD to generate DataSet primary keys
    By Application Development in forum CSharp
    Replies: 1
    Last Post: 11-16-2007, 11:50 AM
  2. Dataset with Primary key
    By Application Development in forum DOTNET
    Replies: 0
    Last Post: 08-16-2007, 09:39 AM
  3. Returning Dataset or Datatable via Web Service
    By Application Development in forum DOTNET
    Replies: 15
    Last Post: 02-26-2007, 12:37 PM
  4. Is this viable method - returning DataSet
    By Application Development in forum DOTNET
    Replies: 2
    Last Post: 11-20-2006, 06:02 AM
  5. Replies: 1
    Last Post: 10-30-2003, 09:39 PM