foreach (string num in ld2.Keys)
{
double state;
int i;
for (i = 0; i < states.Count; i++)
{
cmd = mdb.getCommand("select value V " +
" from TAB_CHART_DATA " +
" where TIMESTAMP = (select max(TIMESTAMP) " +
" from TAB_CHART_DATA " +
" where chart_type= " + chart_type +
" and upper(upper(state)) = '" + states[i] + "' " +
" and CSIS_ID = " + CSISPID +
" and baselinecode like '" + num + "'" +
" ) " +
" and chart_type = " + chart_type +
" and upper(state) = '" + states[i] + "' " +
" and CSIS_ID = " + CSISPID +
" and baselinecode like '" + num + "'"
);
state = mdb.ExecSQLAndGetFirstInt(cmd);
}
}
此循环运行超过3000次。
答案 0 :(得分:3)
获取一个查询中的所有行并循环遍历代码中的结果集,而不是打开游标并终止数据库。