for (int i = 0; i < dt.Rows.Count; i++) { string s = "select count(*) from " + dt.Rows[i]["AliasName"] + ".dbo.web_historydata where factoryid=" + dt.Rows[i]["FactoryID"] + " and datetime >dateadd(HOUR,-1,GetDate())"; int count = my_SqlHelper.SelectCounts(s); if (count<=0) { Log.Save("蜀云泉真帅啊"); } }
如果不知道列名是啥子的话,也可以这样遍历
for (int i = 0; i < dataTable.Rows.Count; i++) { for (int j = 0; j < dataTable.Columns.Count; j++) { Console.WriteLine(dataTable.Rows[i][j].ToString()); } }