System.ComponentModel.Win32Exception: The network path was n
本文关键字:path was network The ComponentModel Win32Exception System | 更新日期: 2023-09-27 18:02:06
我在visual studio中创建了一个数据库,然后在我的代码中添加连接字符串
string connString = "Data Source=(LocalDB)'v11.0;AttachDbFilename='"D:''POS''App_Data''POS.mdf'";Integrated Security=True";
当我试图从数据库
获取数据时,我得到了这个异常[Win32Exception (0x80004005): The network path was not found]
[SqlException (0x80131904):与网络相关或特定于实例的异常在建立到SQL Server的连接时发生错误。的未找到服务器或无法访问服务器。验证实例SQL Server已配置为允许远程访问连接。提供程序:命名管道提供程序,错误:40 -无法(打开SQL Server的连接)]
System.Data.SqlClient.SqlInternalConnectionTds . .男星(DbConnectionPoolIdentity连接选项,SqlCredential凭证,对象提供信息,字符串newPassword, SecureStringnewSecurePassword, Boolean redirectedUserInstance, SqlConnectionStringuserConnectionOptions, SessionData,DbConnectionPool pool, String accessToken, BooleanapplyTransientFaultHandling) + 970
System.Data.SqlClient.SqlConnectionFactory.CreateConnection (DbConnectionOptionsDbConnectionPoolKey poolKey,对象poolGroupProviderInfo,DbConnection owningConnectionDbConnectionOptions userOptions) +802
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection (DbConnectionPoolDbConnection owningObject, DbConnectionOptions选项,DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
System.Data.ProviderBase.DbConnectionPool.CreateObject (DbConnectionowningObject, DbConnectionOptions, userOptions, DbConnectionInternaloldConnection) + 682
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest (DbConnectionowningObject, DbConnectionOptions, userOptions, DbConnectionInternaloldConnection) + 89
System.Data.ProviderBase.DbConnectionPool.TryGetConnection (DbConnectionowningObject, UInt32 waitformultipleobjecttimeout,布尔值allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptionsuserOptions DbConnectionInternal&连接)+ 426
System.Data.ProviderBase.DbConnectionPool.TryGetConnection (DbConnectionowningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
1 retry, DbConnectionOptionsuserOptions, DbConnectionInternal oldConnection, DbConnectionInternal&连接)+ 191
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal (DbConnection
为什么在数据源=LocalDB中有一个前提?
试试这个:
string connString = "Data Source=(LocalDB)''v11.0;AttachDbFilename='"D:''POS''App_Data''POS.mdf'";Integrated Security=True";
把
Data Source= (localdb)'v11.0
Data Source= (localdb)''v11.0