我在数据集上执行多个选择.所有这些选择的总记录数应该与数据集中的记录总数相匹配,但不匹配.(所有选择的总和都少.)我读过.Net 1.1 Select有多个AND条件的错误,但这是VS2005和.Net 2.0.
这是代码:注意:没有填充某些行的类别值.
string Filter; Filter = "Category = 'HIGH'"; Response.Write("High: " + dslErrors.Tables[0].Select(Filter).GetLength(0).ToString() + "
"); int TotalRecords = dslErrors.Tables[0].Rows.Count; //This is correct Filter = "Category = 'MEDIUM'"; Response.Write("Medium: " + dslErrors.Tables[0].Select(Filter).GetLength(0).ToString() + "
"); Filter = "Category = 'LOW'"; Response.Write("Low Error Count: " + dslErrors.Tables[0].Select(Filter).GetLength(0).ToString() + "
"); Filter = "((Category <> 'HIGH') AND (Category <> 'MEDIUM') AND (Category <> 'LOW'))"; Response.Write("Other: " + dslErrors.Tables[0].Select(Filter).GetLength(0).ToString() + "
");
Welbog.. 7
如果有任何记录,这Category
是dbnull
,那么他们将不会匹配,并且表达您列出.
我建议将你的姓氏filter
改为:
"( ( (Category <> 'HIGH') AND (Category <> 'MEDIUM') AND (Category <> 'LOW') ) OR Category IS NULL )";
它不起作用的原因是因为与dbnull的比较产生了null而不是预期的false.
如果有任何记录,这Category
是dbnull
,那么他们将不会匹配,并且表达您列出.
我建议将你的姓氏filter
改为:
"( ( (Category <> 'HIGH') AND (Category <> 'MEDIUM') AND (Category <> 'LOW') ) OR Category IS NULL )";
它不起作用的原因是因为与dbnull的比较产生了null而不是预期的false.