Primary key in a dataset

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top