Офисная сеть SQLEXPRESS - проблема подключения Winform - PullRequest
0 голосов
/ 18 ноября 2011

Я создал Winform, которая подключается к SQL Server Express x64 с использованием строки Trusted Connection.

На компьютере разработчика (на котором также работает SQL Server) Winform работает на 100%, в результате получается строка подключения:

Persist Security Info=False;
Integrated Security=true;
Initial Catalog=BushBreaksLodgeManager;
server=.\SQLEXPRESS

Как только я попробую ту же самую форму выигрыша на сетевом ПК, он не сможет подключиться. На удаленной машине я вижу машину разработки через Сетевые места, т.е. \\JOHN-WIN7PC

Строка подключения удаленного ПК:

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)

1 Ответ

0 голосов
/ 05 февраля 2012

Я думаю, что ошибка очень проста.При подключении к SQL Server имя сервера не ставится перед \\, поэтому вместо server=\\JOHN-WIN7PC\SQLEXPRESS следует использовать server=JOHN-WIN7PC\SQLEXPRESS.

...