应用程序加载,但是当应用程序尝试连接到SQL时,需要一段时间才能加载,然后返回错误。使用DataLink(.udl文件)测试连接属性时,它是成功的。该应用程序在我的本地计算机上运行良好。我到处搜索,设置都很好,网络管理员验证了防火墙,一切都设置正确。我错过了什么?
我注意到它在错误中提到了名称管道,但是,这不应该使它成为TCP吗?
SQLConnectionString.NetworkLibrary = "dbmssocn";
这是我的连接字符串方法:
public string GetReachoutConnectionString()
{
SqlConnectionStringBuilder SQLConnectionString = new SqlConnectionStringBuilder();
SQLConnectionString.TypeSystemVersion = "Latest";
SQLConnectionString.NetworkLibrary = "dbmssocn";
SQLConnectionString.DataSource = "10.10.xxx.xx,1433";
SQLConnectionString.InitialCatalog = "cat";
SQLConnectionString.UserID = "xxx";
SQLConnectionString.Password = "xxx";
SQLConnectionString.MultipleActiveResultSets = true;
SQLConnectionString.ApplicationName = "Website";
return SQLConnectionString.ConnectionString;
}
这是我得到的错误:
[Win32Exception(0x80004005):. 找不到网络路径]
[SqlException(0x80131904):与网络相关或特定于实例的 建立与SQL Server的连接时发生错误。该 服务器未找到或无法访问。验证该实例 名称是正确的,并且SQL Server配置为允许远程 连接。 (提供者:命名管道提供者,错误:40 - 不能 打开与SQL Server的连接)]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,SqlConnectionString connectionOptions,SqlCredential 凭证,Object providerInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData, DbConnectionPool池,String accessToken,Boolean applyTransientFaultHandling)+1394
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo, DbConnectionPool池,DbConnection owningConnection, DbConnectionOptions userOptions)+1120
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(类DBConnectionPool pool,DbConnection owningObject,DbConnectionOptions选项, DbConnectionPoolKey poolKey,DbConnectionOptions userOptions)+70
System.Data.ProviderBase.DbConnectionPool.CreateObject(的DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)+964
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(的DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)+114
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionOptions userOptions,DbConnectionInternal&连接)+1631
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection owningObject,TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +117
1重试,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& 连接)+267
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(的DbConnection outerConnection,DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +318
1 重试)+211
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 重试)+393 System.Data.SqlClient.SqlConnection.Open()+122
System.Data.Common.DbDataAdapter.FillInternal(DataSet数据集, DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,CommandBehavior行为)+177
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32 startRecord,Int32 maxRecords,String srcTable,IDbCommand命令, CommandBehavior行为)+182
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,String srcTable)+123
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments 参数)+2964
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)+369 System.Web.UI.WebControls.ListControl.PerformSelect()+43
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()+139 System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e)+36
System.Web.UI.Control.PreRenderRecursiveInternal()+ 107 7 System.Web.UI.Control.PreRenderRecursiveInternal()+204
System.Web.UI.Control.PreRenderRecursiveInternal()+204
System.Web.UI.Control.PreRenderRecursiveInternal()+204
System.Web.UI.Control.PreRenderRecursiveInternal()+204
System.Web.UI.Control.PreRenderRecursiveInternal()+204
System.Web.UI.d__249.MoveNext()+ 1400 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)+13847892
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)+61
System.Web.Util.WithinCancellableCallbackTaskAwaiter.GetResult()+32
System.Web.UI.d__523.MoveNext()+ 9283
答案 0 :(得分:0)
我想通了, web.config 文件中有一个杂项连接字符串导致程序返回该错误。当我测试不同的连接方法时,它由visual studio自动添加。我删除它,它的工作原理。我的连接字符串没有错,当下一页加载并尝试使用自动输入的其他连接字符串时,它失败了。这就是为什么使用GUI界面有时会引起问题。