I assume you are asking to add a primary key just for processing while
the dataset/datatable is in memory and aren't trying to write it back
out anywhere.
You can add a primary key by using the PrimaryKey property on a
DataTable
You can use the following code as an example:
Dim lds as DataSet = GetSomeDataSet()
For Each ldt As DataTable In lds.Tables
ldt.PrimaryKey = New DataColumn() {ldt.Columns("ColumnName")}
Next
-------
A couple things to note here. This iterates through each datatable
that's returned in the dataset, you can run the line inside the
for..each by itself if you only want to create a PrimaryKey for just one
table.
Also, if you want to make a multi-column primary key then the line
inside the for..each would look something like this:
ldt.PrimaryKey = New DataColumn() _
{ldt.Columns("ColumnName1"), ldt.Columns("ColumnName2")}
Hopefully this makes sense...
Brian Swanson
I am working with vfp free tables - there are no primary keys in the
original tables and they can't be added to the backend (because they are