再分析分析你的情况看能不能用 (not) exists ,你用 累加 <> 或者 in 很容易就溢出了,
建议你用not in 试一下StringBuilder sqlCondition=new StringBuilder(); foreach (DictionaryEntry de in requestIDs) { sqlCondition.Append(de.Value.ToString()+","); } if(sqlCondition.Length>0) { filterStr=" ID not in ("+sqlCondition.ToString().Substring(0,sqlCondition.Length-1)+") and ID<>-1"; } else { filterStr="ID<>-1"; } DataRow[] dtRows = dt.Select(filterStr);
建议你用not in 试一下StringBuilder sqlCondition=new StringBuilder(); foreach (DictionaryEntry de in requestIDs) { sqlCondition.Append(de.Value.ToString()+","); } if(sqlCondition.Length>0) { filterStr=" ID not in ("+sqlCondition.ToString().Substring(0,sqlCondition.Length-1)+") and ID<>-1"; } else { filterStr="ID<>-1"; } DataRow[] dtRows = dt.Select(filterStr);
foreach (DictionaryEntry de in requestIDs)
{
sqlCondition.Append(de.Value.ToString()+",");
}
if(sqlCondition.Length>0)
{
filterStr=" ID not in ("+sqlCondition.ToString().Substring(0,sqlCondition.Length-1)+") and ID<>-1";
}
else
{
filterStr="ID<>-1";
}
DataRow[] dtRows = dt.Select(filterStr);
建议你用not in 试一下StringBuilder sqlCondition=new StringBuilder();
foreach (DictionaryEntry de in requestIDs)
{
sqlCondition.Append(de.Value.ToString()+",");
}
if(sqlCondition.Length>0)
{
filterStr=" ID not in ("+sqlCondition.ToString().Substring(0,sqlCondition.Length-1)+") and ID<>-1";
}
else
{
filterStr="ID<>-1";
}
DataRow[] dtRows = dt.Select(filterStr);
多谢以上各位 wpfLove, guwei4037, lasesiwen, reenjie的回复。 当时头脑发热没有想到 Not in, 这个应该是会很有帮助的。 谢谢各位, 下星期会公司去试试!!To lasesiwen, 设计是历史遗留问题, 暂时还大改不了。 多谢。