简体   繁体   English

SQL Server 2008 R2 Express LocalDB / v11.0连接问题

[英]Sql Server 2008 R2 Express LocalDB/ v11.0 connectivity issues

I have a windows forms application which makes use of the local database (Service Database) " .mdf " file. 我有一个Windows窗体应用程序,该应用程序使用本地数据库(服务数据库)“。 mdf ”文件。 I am able to connect to this database using the connection string below from the development machine. 我可以使用开发机器下面的连接字符串连接到该数据库。

 <connectionStrings> <add name="DbConnectionString" connectionString="Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\MDFDb.mdf;Integrated Security=SSPI;Connect Timeout=30" providerName="System.Data.SqlClient;Trusted_Connection=Yes;" /> </connectionStrings> 

I am trying to publish the application now. 我正在尝试发布该应用程序。 When i attempt to install the application on a different machine. 当我尝试在另一台计算机上安装应用程序时。 The application throws an error as shown below. 应用程序将引发错误,如下所示。

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at DataLayer.Common.DbOperations.GetDataSet(String CommandName, CommandType cmdType)

This error occurs only when i try to install in a different machine. 仅当我尝试在其他计算机上安装时,才会发生此错误。 I am not sure what I am missing? 我不确定我缺少什么?

We have deployed a winforms app which allows the user to connect to either localdb / sql express, or a full version of sql server. 我们已经部署了一个winforms应用程序,该应用程序允许用户连接到localdb / sql Express或完整版本的sql server。 If the choose localdb we have been using this connection string: 如果选择localdb,我们一直在使用以下连接字符串:

Data Source=(localdb)\v11.0;AttachDbFileName="C:\localdbfilename.mdf";Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;

I hope that helps. 希望对您有所帮助。 It has been working for us. 它一直在为我们工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM