我們最近推出了一個新的網站......在高峯時段有大約150個用戶活躍。在繁忙時段,我們每隔幾分鐘就會遇到一個問題,下面列出了例外情況。SQL Server連接問題
System.Web.HttpUnhandledException:
Exception of type 'System.Web.HttpUnhandledException' was thrown.
---> System.Data.SqlClient.SqlException: The client was unable to establish a connection because of an error during connection initialization process before login.
Possible causes include the following:
the client tried to connect to an unsupported version of SQL Server;
the server was too busy to accept new connections;
or there was a resource limitation (insufficient memory or maximum allowed connections) on the server. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)
我們的數據訪問層使用以下語法調用各種DataTableAdapter。
編輯
是,da
是分配給DataTableAdapter名稱。沒有connection.Open()
,因爲DataTableAdapter處理所有這些,對嗎?
using(TheDataLayer.some.strongly.typedNameTableAdapters.suchAndSuchTableAdapter da = new TheDataLayer.some.strongly.typedNameTableAdapters.suchAndSuchTableAdapter())
{
StronglyTyped.DataTable dt = new StronglyTyped.DataTable();
da.FillByVariousArguments(dt, ..., ...);
//da.Dispose();
return something;
}
連接字符串看起來像:
<add name="MyConnectionString"
connectionString="Data Source=myDBServerName;Initial Catalog=MyDB;User ID=MyUserName;Password=MyPassword"
providerName="System.Data.SqlClient" />
我試圖排除在代碼是問題。有什麼「簡單的」可以做到儘量減少這個問題?
感謝。
如果你正在使用'using'語句,爲什麼你在裏面調用'Dispose()'? –
您將不得不向我們展示您的'conn.Open'發生的代碼。目前我們沒有看到;這就是問題所在。 –
是的,我明白.Dispose()不是必要的和多餘的,但這不會是這個問題的原因,是嗎?我試圖在謹慎的一面犯錯。現在忽略該行〜 – Robert