asp.net网站程序上传到服务器后可以访问,但是运行一段时间之后经常出现如下错误,必须要在服务器回收进程池后才能恢复正常。有人说可能是程序中有死循环,或者有未关闭的数据连接,那么,怎样检查出程序文件中的这个死循环或者未关闭的数据连接呢?有些什么手段?
错误信息如下:
Server Error in '/' Application.
--------------------------------------------------------------------------------未指定的错误
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: 未指定的错误Source Error:
Line 376:
Line 377: if (conn.State != ConnectionState.Open)
Line 378: conn.Open();
Line 379:
Line 380: cmd.Connection = conn;
Source File: d:\17gf\App_Code\OleDbHelper.cs Line: 378 Stack Trace:
[OleDbException (0x80004005): 未指定的错误]
System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +1054817
System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +53
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.OleDb.OleDbConnection.Open() +37
OleDbHelper.PrepareCommand(OleDbCommand cmd, OleDbConnection conn, OleDbTransaction trans, CommandType cmdType, String cmdText, OleDbParameter[] cmdParms) in d:\17gf\App_Code\OleDbHelper.cs:378
OleDbHelper.ExecuteReader(CommandType cmdType, String cmdText, OleDbParameter[] commandParameters) in d:\17gf\App_Code\OleDbHelper.cs:141
_Default.bindArea() in d:\17gf\Default.aspx.cs:50
_Default.Page_Load(Object sender, EventArgs e) in d:\17gf\Default.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
错误信息如下:
Server Error in '/' Application.
--------------------------------------------------------------------------------未指定的错误
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: 未指定的错误Source Error:
Line 376:
Line 377: if (conn.State != ConnectionState.Open)
Line 378: conn.Open();
Line 379:
Line 380: cmd.Connection = conn;
Source File: d:\17gf\App_Code\OleDbHelper.cs Line: 378 Stack Trace:
[OleDbException (0x80004005): 未指定的错误]
System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +1054817
System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +53
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.OleDb.OleDbConnection.Open() +37
OleDbHelper.PrepareCommand(OleDbCommand cmd, OleDbConnection conn, OleDbTransaction trans, CommandType cmdType, String cmdText, OleDbParameter[] cmdParms) in d:\17gf\App_Code\OleDbHelper.cs:378
OleDbHelper.ExecuteReader(CommandType cmdType, String cmdText, OleDbParameter[] commandParameters) in d:\17gf\App_Code\OleDbHelper.cs:141
_Default.bindArea() in d:\17gf\Default.aspx.cs:50
_Default.Page_Load(Object sender, EventArgs e) in d:\17gf\Default.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
{
connection.Open();
// Do work here; connection closed on following line.
}
SqlConnection用完了要记得关闭,
不然的话,每个用户访问都会产生一个SqlConnection
很占资源的
象死循环,
try...catch
读写文件
数据库读写(打开、关闭)都有可能占用资源,建议:到数据库的资源管理里看看!