简体   繁体   English

vb.net 中数据表的不同操作

[英]distinct operation for datatable in vb.net

I have one DataTable with three columns "HOUSE_BILL_KEY","HOUSE_BILL_SRC_ID" and "SRC_RCRD_ID" and has data as shown我有一个包含三列“HOUSE_BILL_KEY”、“HOUSE_BILL_SRC_ID”和“SRC_RCRD_ID”的数据表,并具有如图所示的数据

在此处输入图片说明

I want only distinct values from datatable like我只想要来自数据表的不同值,例如在此处输入图片说明

how I will do it in behind the code?我将如何在代码后面做到这一点?

It's probably better to do that in the SQL query that you're using to populate your dtCntnrHoubill table.在用于填充dtCntnrHoubill表的 SQL 查询中执行此操作可能会更好。 Something like:就像是:

SELECT DISTINCT HOUSE_BILL_KEY, HOUSE_BILL_SRC_ID, SRC_RCRD_ID
FROM dtCntnrHoubill

But if you really want it in code behind, you can use LINQ:但是如果你真的想要它在代码后面,你可以使用 LINQ:

Dim distinctResults = dtCntnrHoubill.Distinct()

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

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