当前位置:Gxlcms >
数据库问题 >
sql查询结果存入DataTable,然后从DataTable取数据
sql查询结果存入DataTable,然后从DataTable取数据
时间:2021-07-01 10:21:17
帮助过:23人阅读
(
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());
}
}
sql查询结果存入DataTable,然后从DataTable取数据
标签:结果 table class where date() web ons row time