有关datatable跟数据库的有关问题
有关datatable跟数据库的问题

求不能连接的总时间,及次数,求思路,用编程
for (int i = 0; i < count; i++)
{
if (dataResult.Rows[i][2].ToString() != "Freelance2000OPCServer.89.1不能连接")
{
dataResult.Rows.RemoveAt(i);
}
}
次数 newrow["count"]+=“1”.tostring();
只能想到这样写,但是
------解决思路----------------------
求不能连接的总时间,及次数,求思路,用编程
for (int i = 0; i < count; i++)
{
if (dataResult.Rows[i][2].ToString() != "Freelance2000OPCServer.89.1不能连接")
{
dataResult.Rows.RemoveAt(i);
}
}
次数 newrow["count"]+=“1”.tostring();
------解决思路----------------------
int 不能连接的总数 = dataResult.AsEnumerable().Count(p => p.Field<string>("具体描述").Contains("不能连接"));
DataTable 正常连接的数据 = dataResult.AsEnumerable().Where(p => !p.Field<string>("具体描述").Contains("不能连接")).CopyToDataTable<DataRow>();