超出系统资源 [英] System resource exceeded
本文介绍了超出系统资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用C#Application与MS-Acces建立连接并在执行insert和select语句后关闭每个连接。
但是在执行了600-700次后,它会抛出一个Execption:超出系统资源
时间没有CPU利用率和内存利用率。
重启应用程序后,它也能正常运行。
以下是我正在使用的代码段:
Hi,
I am using C# Application to make the connection with MS-Acces and closing each connection after executing insert and select statements.
But after executing 600-700 times, it is throwing an Execption: "System resource exceeded"
There are no CPU utilization and memory utilization that time.
Also after restarting the application, it works normaly.
Below is the code snippet I am using:
try
{
//Setting private fields.
this.strMdbFile = paramstrMdbFile;
this.strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=;Data Source=" + paramstrMdbFile + ";";
/*Opening connection.*/
conDBData = new OleDbConnection(strConnString);
conDBData.Open();
/* Some statements*/
conDBData.Close();
}
catch (Exception ex)
{
string strError = ex.Message;
MessageBox.Show(strError);
}
finally
{
if (conDBData != null)
{
if (conDBData.State == ConnectionState.Open)
{
conDBData.Close();
}
}
}
请提示。
Kindly suggest.
推荐答案
如果使用使用
语句来包装所有这些,那么连接对象应该正确处理 - 请参阅 http://msdn.microsoft.com/en-us/library/yh598w02.aspx [ ^ ]
有一个代码项目文章解释了的内容理解C#中的使用语句 [ ^ ]
这里是一个很好的dotnetperls解释使用数据库连接(虽然sql not ole)
<小时ef =http://www.dotnetperls.com/sqlconnection> http://www.dotnetperls.com/sqlconnection [ ^ ]
If you use ausing
statement to wrap all of this then the connection objects should get disposed properly - see http://msdn.microsoft.com/en-us/library/yh598w02.aspx[^]
There's a codeproject article that explains what's going on Understanding the 'using' statement in C#[^]
and here is a good dotnetperls explanation using a database connection (albeit sql not ole)
http://www.dotnetperls.com/sqlconnection[^]
你有没有确定问题所在?
Did you ever determine what the problem was here?
这篇关于超出系统资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文