ORA-01000: maximum open cursors exceeded 大家帮我看看这段代码有什么问题
这段循环是这样的foreach (DataRow dr in ds1.Tables[0].Rows)
{
if (dboperate.HasRows("select * from c_score where id = " + dr[0].ToString() ) == false )
{
//in
try
{
//long result = dboperate.RunSqlOnly(" insert into c_score(id, seq, score, score1) values ("
// + dr[0].ToString() + "," + dr[1].ToString() +
// ", to_date('" + dr[3].ToString() + "','HH24:MI:SS'), to_date('"
// + dr[2].ToString() + "','HH24:MI:SS'))");
strSql = strSql + " insert into c_score(id, seq, score, score1) values ("
+ dr[0].ToString() + "," + dr[1].ToString() +
", to_date('" + dr[3].ToString() + "','HH24:MI:SS'), to_date('"
+ dr[2].ToString() + "','HH24:MI:SS')); ";
i++;
}
catch (Exception ex)
{
dboperate.close();
}
}
else
{
//update
strInfo = strInfo + dr[0].ToString() + "\n";
try
{
//long result = dboperate.RunSqlOnly(" update c_score set seq = " + dr[1].ToString() +
// ",score = to_date('" + dr[3].ToString() + "','HH24:MI:SS'),score1 = to_date('"
// + dr[2].ToString() + "','HH24:MI:SS') where id = " + dr[0].ToString());
strSql = strSql + " update c_score set seq = " + dr[1].ToString() +
",score = to_date('" + dr[3].ToString() + "','HH24:MI:SS'),score1 = to_date('"
+ dr[2].ToString() + "','HH24:MI:SS') where id = " + dr[0].ToString() + "; ";
i++;
}
catch (Exception ex)
{
dboperate.close();
}
}
//
if( i == 50)
{
strSql = strSql + " end;";
dboperate.RunSql(strSql);
strSql = "begin ";
i = 0;
}
}
strSql = strSql+ "end;";
//dboperate.open();
dboperate.RunSql( strSql);
以下是用到的2个函数
---------------------------------------------------
public static bool HasRows(string strSql)
{
bool bresult = false;
open();
cmd = new OracleCommand(strSql, cn);
odr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
if (odr.HasRows == true)
bresult = true;
else
bresult = false;
close();
return bresult;
}
--------------------------------------------------
public static long RunSql(string strSql)
{
long rows = 0;
open();
cmd = new OracleCommand(strSql, cn);
rows = cmd.ExecuteNonQuery();
close();
return rows;
}
----------------------------------------------------
在两台机器上一台会出现 ORA-01000: maximum open cursors exceeded 这个错误
另一台正常 看了好多网页说是oracle设置和代码的错误
大家帮我看看代码哪里没有关闭好。。。。 --------------------编程问答-------------------- 先查看数据库中有没有重复的记录 如果有就更新 如果没有就执行插入操作
因为插入的数量和更新的数量的都很多 所以就没有一条一条的插入,我现在是50条执行一次 --------------------编程问答-------------------- 。。。我找到问题了
Dispose(); 这个没加 靠。。。。 --------------------编程问答-------------------- 呵呵,接分
补充:.NET技术 , ASP.NET