【发布时间】:2012-02-18 16:54:49
【问题描述】:
我有包含以下列的 DataTable:
ClientID date numberOfTransactions price
ClientID 是字符串类型,我需要确保它的内容对于表中的每个值都包含“A-”和“N6”。
我需要从 DataTable 中删除所有行,其中第一列 (ClientID) 不包含“A-”和“N6”(一些总计和其他不必要的数据)。如何从 DataTable 中专门选择和删除这些行?
我知道:
foreach (DataRow row in table.Rows) // Loop over the rows.
{
//Here should come part "if first column contains mentioned values
}
这个我也知道
If (string.Contains("A-") == true && string.Contains("N6") == true)
{
//Do something
}
我需要帮助如何为每行的第一列实现此功能。
【问题讨论】:
-
你试过什么查询..?还有你使用 SQL Server、MYSQL 等什么数据库?
-
这个问题太模糊了;给我们更多的细节,请
-
我相信 OP 只是想从 DataTable.Rows 集合中删除某些 DataRows(在内存中),因此知道数据来自哪里实际上可能无关紧要(因此他/她感到困惑)。