Primary key in a dataset

G

Guest

I have seen in msdn article that if the SelectCommand of the dataadapter
retrieves results from an OUTER JOIN the DataAdapter will not set a
PrimaryKey value for the resulting DataTable and we need to explicitly define
the primary key for the table.

What is the reason for not setting primary key ?

Any suggestions, mostly welcome.

Regards
G.V.Srinivasa Rao
 
M

Mona

Hi Srinivasa,

The reason why the DataAdapter will not set a PrimaryKey value for the resulting DataTable from an Outer Join
is that the resultant table of an Outer Join may have duplicate rows which is not possible with the primary key.
You will need to define the PrimaryKey yourself to ensure that duplicate rows are resolved correctly.

HTH

Mona
 
G

Guest

Hi Mona,

Thanks for your help. Is it the same case with inner join also .... as
if we inner join two tables ... duplicate rows may come in the result.

Regards
G.V.Srinivasa Rao
 
M

Mona

Hi Srinivasa,

The Inner Join is like a union, it takes all the rows from both the tables
where there is a match.
So in Inner Join, the probability of duplicate rows increases considerably.

HTH

Mona
 

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