简体   繁体   English

如何从数据行获取主键列?

[英]How to get the primary key column from a data row?

In my code there is a data row. 在我的代码中有一个数据行。 Is there a way to get the primary key from this or no? 有没有办法从中获取主键? My code is: 我的代码是:

var PK = data_row.PrimaryKey;

However, this I looked up in the MS docs and there is no PrimaryKey property if a data row, there is a property like that for the data table but I don't have the data table here. 但是,我在MS docs中查询了这个信息,如果有数据行,则没有PrimaryKey属性,该数据表具有类似的属性,但是这里没有数据表。

You could try the following: 您可以尝试以下方法:

var PK = data_row.Table.PrimaryKey;

this gets the primary key column from the DataTable that the DataRow comes from. 这将从DataRow来自的DataTable中获取主键列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM