0
我創建了一個使用Trusted Connection字符串連接到SQL Server Express x64的Winform。辦公網絡SQLEXPRESS - 連接Winform問題
在開發機(SQL Server在其上運行也一樣)在WinForm工程100%,生成的連接字符串是:
Persist Security Info=False;
Integrated Security=true;
Initial Catalog=BushBreaksLodgeManager;
server=.\SQLEXPRESS
當我嘗試聯網PC上一樣贏形式它無法連接。在遠程機器上,我可以看到在開發計算機通過網絡的地方,即\\JOHN-WIN7PC
遠程PC的產生的連接字符串是:
Persist Security Info=False;
Integrated Security=true;
Initial Catalog=BushBreaksLodgeManager;
server=\\JOHN-WIN7PC\SQLEXPRESS
我也啓用了TCP-IP SQL Server上(它被設置爲<default>
),關閉了所有的防火牆,防惡意軟件(不應該這樣做會干擾),防病毒軟件也不會安裝在任何一臺機器上。
SQL database settings are as follows:
==================================================
Authentication method: Windows Authentication
Database: BushBreaksLodgeManager
ServerName: JOHN-WIN7PC\SQLEXPRESS
Instancename: SQLEXPRESS
Computername: JOHN-WIN7PC
Sql Server settings
==================================================
Mixed mode (Win auth and Sql Server)
Connections -> Allow remote connections = true
在這方面的任何幫助,我很茫然,將不勝感激。
我已經粘貼了以下異常:
2011/11/18 04:55:50 PM : Process: UtilsDatabase -> TestDatabaseConnection
2011/11/18 04:56:05 PM : Process: UtilsDatabase -> TestDatabaseConnection Connection failed
2011/11/18 04:56:05 PM : Settings value -> UseIntergratedSecurity: False
2011/11/18 04:56:05 PM : Settings value -> Server: \\JOHN-WIN7PC\SQLEXPRESS
2011/11/18 04:56:05 PM : Settings value -> Database name: BushBreaksLodgeManager
2011/11/18 04:56:05 PM : Connection String: Persist Security Info=False;Integrated Security=true;Initial Catalog=BushBreaksLodgeManager;server=\\JOHN-WIN7PC\SQLEXPRESS
==================== New Exception ====================
2011/11/18 04:56:05 PM
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: 25 - Connection string is not valid)
.Net SqlClient Data Provider
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at BushBreaksLodgeManager.UtilsDatabase.TestDatabaseConnection()
Void OnError(System.Data.SqlClient.SqlException, Boolean)
這是否屬於域環境?是否已將運行遠程軟件的用戶創建爲服務器上的登錄/用戶? –
這是2008年還是2005年的版本?我記得在Express 2005中,你必須明確地告訴它接受遠程連接。不知道它是如何在版本2008和2008R2。 – ssarabando
不,它完全屬於單一辦公室。不需要安全性,因此可信連接字符串。他們沒有要求任何細節。應該簡單地通過提供數據庫名稱和sql server路徑和服務器名稱來連接到服務器。 –