检查数据表中是否存在字符串/记录 [英] Check if String / Record exists in DataTable

查看:18
本文介绍了检查数据表中是否存在字符串/记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串,我需要检查 DataTable dtPs.Rows 中的任何列item_manuf_id"是否等于某个值

I have a String and I need to check if any column "item_manuf_id" in DataTable dtPs.Rows equals to certain value

我可以遍历所有行并进行比较

I can loop over all Rows and compare

String id = dtPs.Rows[number]["item_manuf_id"].ToString()
if ("some value".equals(id)) etc.

但我想知道是否有任何方法可以检查 DataTable 是否包含记录

but I am wondering if there is any way to check if DataTable contains the record

推荐答案

类似这样的事情

 string find = "item_manuf_id = 'some value'";
 DataRow[] foundRows = table.Select(find);

这篇关于检查数据表中是否存在字符串/记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆