下面的例子查三个主键:private void FindInMultiPKey(DataTable myTable){
DataRow foundRow;
// Create an array for the key values to find.
object[]findTheseVals = new object[3];
// Set the values of the keys to find.
findTheseVals[0] = "John";
findTheseVals[1] = "Smith";
findTheseVals[2] = "5 Main St.";
foundRow = myTable.Rows.Find(findTheseVals);
// Display column 1 of the found row.
if(foundRow != null)
Console.WriteLine(foundRow[1]);
}
DataRow foundRow;
// Create an array for the key values to find.
object[]findTheseVals = new object[3];
// Set the values of the keys to find.
findTheseVals[0] = "John";
findTheseVals[1] = "Smith";
findTheseVals[2] = "5 Main St.";
foundRow = myTable.Rows.Find(findTheseVals);
// Display column 1 of the found row.
if(foundRow != null)
Console.WriteLine(foundRow[1]);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货