当为一列的时候
table.PrimaryKey=new DataColumn[]{table.Columns["CustID"]};
或者DataColum[] columns=new DataColumn[1];
columns[0]=table.columns["CustID"];
table.PrimaryKey=columns;
当为多列的时候
table.PrimaryKey =new DataColumn[]{table.Columns["CustId=D"],
table.Columns["CustName"]};
或者
DataColumn[] keyColumn = new DataColumn[2];
keyColumn[0] = table.Columns["CustLName"];
keyColumn[1] = table.Columns["CustFName"];
table.PrimaryKey = keyColumn;