OleDbException系统资源超出 [英] OleDbException System Resources Exceeded

查看:932
本文介绍了OleDbException系统资源超出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码执行一个简单的插入命令。如果它被称为连续2000次(插入2000行)与消息的OleDbException =系统资源超过被抛出。是否有别的我应该做的事,以腾出资源的东西吗?



 使用(OleDbConnection的康恩=新的OleDbConnection(的connectionString))
使用(OleDbCommand的CMD =新的OleDbCommand(CommandText中,康涅狄格州))
{
conn.Open();
cmd.ExecuteNonQuery();
}


解决方案

系统资源超过误差不从托管代码来了,它从你杀死你的数据库来(JET?)



您正在打开的方式来许多连接,方法快...



一些提示:




  • 避免不开放为每一个命令,一个新的连接往返,并使用一个连接进行插入。

  • 确保数据库连接池的工作(不知道是否与OLEDB连接的工作)。

  • 考虑采用了更优化的方式来插入数据。



你试过吗?

 使用(OleDbConnection的康恩=新的OleDbConnection(connstr))
{
,而(IHaveData)
{使用
(OldDBCommand CMD =新OldDBCommand())
{
cmd.Connection =康恩;
cmd.ExecuteScalar();
}
}
}


The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources?

using (OleDbConnection conn = new OleDbConnection(connectionString))
using (OleDbCommand cmd = new OleDbCommand(commandText, conn))
{
    conn.Open();
    cmd.ExecuteNonQuery();
}

解决方案

The system resources exceeded error is not coming from the managed code, its coming from you killing your database (JET?)

You are opening way to many connections, way to fast...

Some tips:

  • Avoid roundtrips by not opening a new connection for every single command, and perform the inserts using a single connection.
  • Ensure that database connection pooling is working (Not sure if that works with OLEDB connections).
  • Consider using a more optimized way to insert the data.

Have you tried this?

using (OleDBConnection conn = new OleDBConnection(connstr))
{
    while (IHaveData)
    {
        using (OldDBCommand cmd = new OldDBCommand())
        {
            cmd.Connection = conn;
            cmd.ExecuteScalar();
        }
    }
}

这篇关于OleDbException系统资源超出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆