问题描述
我有一个从未在sql Server 2012上出现过问题的应用程序,但是现在尝试在启动时访问sql Server 2019时偶尔会崩溃。
这是事件日志:
Application: MyApplication.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ComponentModel.Win32Exception
Exception Info: System.Data.sqlClient.sqlException
at System.Data.sqlClient.sqlInternalConnectionTds..ctor(System.Data.ProviderBase.DbConnectionPoolIdentity,System.Data.sqlClient.sqlConnectionString,System.Data.sqlClient.sqlCredential,System.Object,System.String,System.Security.securestring,Boolean,System.Data.sqlClient.SessionData,System.Data.ProviderBase.DbConnectionPool,Boolean)
at System.Data.sqlClient.sqlConnectionFactory.CreateConnection(System.Data.Common.DbConnectionoptions,System.Data.Common.DbConnectionPoolKey,System.Data.Common.DbConnection,System.Data.Common.DbConnectionoptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(System.Data.ProviderBase.DbConnectionPool,System.Data.Common.DbConnectionoptions,System.Data.Common.DbConnectionoptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(System.Data.Common.DbConnection,System.Data.ProviderBase.DbConnectionInternal)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(System.Data.Common.DbConnection,System.Data.ProviderBase.DbConnectionInternal)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(System.Data.Common.DbConnection,UInt32,System.Data.ProviderBase.DbConnectionInternal ByRef)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(System.Data.Common.DbConnection,System.Threading.Tasks.taskcompletionsource`1<System.Data.ProviderBase.DbConnectionInternal>,System.Data.ProviderBase.DbConnectionInternal ByRef)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(System.Data.Common.DbConnection,System.Data.ProviderBase.DbConnectionInternal,System.Data.ProviderBase.DbConnectionInternal ByRef)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(System.Data.Common.DbConnection,System.Data.ProviderBase.DbConnectionFactory,System.Data.Common.DbConnectionoptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(System.Data.Common.DbConnection,System.Data.Common.DbConnectionoptions)
at System.Data.sqlClient.sqlConnection.TryOpenInner(System.Threading.Tasks.taskcompletionsource`1<System.Data.ProviderBase.DbConnectionInternal>)
at System.Data.sqlClient.sqlConnection.TryOpen(System.Threading.Tasks.taskcompletionsource`1<System.Data.ProviderBase.DbConnectionInternal>)
at System.Data.sqlClient.sqlConnection.open()
at System.Data.Common.DbDataAdapter.FillInternal(System.Data.DataSet,System.Data.DataTable[],Int32,System.Data.IDbCommand,System.Data.CommandBehavior)
at System.Data.Common.DbDataAdapter.Fill(System.Data.DataTable[],System.Data.CommandBehavior)
at System.Data.Common.DbDataAdapter.Fill(System.Data.DataTable)
at MyApplication.Program.MyDatabaseMethod(System.String)
at MyApplication.Program.Main(System.String[])
这是它崩溃的方法:
public static string MyDatabaseMethod()
{
DataTable dt = new DataTable();
string query = "SELECT TOP 1 col1 FROM mydatabase.dbo.mytable";
sqlDataAdapter da = new sqlDataAdapter(query,myConnectionString);
da.Fill(dt);
string data = dt.Rows[0].Field<string>("col1");
return data;
}
这90%的时间有效,但是偶尔的崩溃变得成问题。错误看起来像超时吗?该数据库非常繁忙,并且每晚晚上同时连接该应用程序的多个实例(〜20个),因此我想知道一次登录的数量是否存在并发问题。查询本身正在访问的表不超过30行。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)