"Tom Archer" <(E-Mail Removed)> wrote
> Just to clarify that I'm understanding this correctly:
>
> ADO.NET can't figure out that the underlying table has a
> primary key so I must explicitly tell it which column is
> the primary key?
>
Tom,
For an untyped DataSet, the primary key information is NOT filled in.
In this case, you'll need to specify which column(s) is the primary key.
However, for a Typed DataSet, then the primary key information
is filled in for you.
e.g.
// Untyped DataSet
DataSet dataSet = new DataSet();
sqlDataAdapter1.Fill(dataSet, "Employees");
int count1 = dataSet.Tables["Employees"].PrimaryKey.Length;
// count1 = 0
// Typed DataSet
EmployeesDataSet employeeDataSet = new EmployeesDataSet();
sqlDataAdapter1.Fill(employeeDataSet.Employees);
int count2 = employeeDataSet.Employees.PrimaryKey.Length;
// count2 = 1
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com