【发布时间】:2014-07-02 20:07:12
【问题描述】:
我有一个项目,其中 SQL Server 和开发都在本地工作。
使用了以下连接字符串:
SqlConnection connection= new SqlConnection("Data Source=.\\MYDB;Initial Catalog=Database;Integrated Security=true");
connection.Open();
我的开发团队现在正在壮大,我希望让其他开发人员访问同一个数据库。
他将需要更改此连接字符串,我们正在尝试尝试更改字符串中的哪些内容 - 到目前为止我们已经尝试过:
SqlConnection connection= new SqlConnection("Data Source=2.221.1.145\\MYDB;Initial Catalog=Database;Integrated Security=true");
connection.Open();
但是在访问页面时会抛出如下错误:
[SqlException (0x80131904): 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: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5352431
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +244
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5363103
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +922
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +518
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +278
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
SQL Server 已启用 TCPIP 协议并正在侦听我系统上的所有 IPAddress。端口 1433 已添加到防火墙,是 UDP 和 TCP 的入站端口,并且 SQL Server Express 实例服务已重新启动。
任何人都可以帮助我们连接字符串吗?此外,我认为集成安全线需要更改。
为了简单起见,我已将更新状态的问题移至新线程:Connection string for SQL Server Express on remote Computer login failed error
【问题讨论】:
-
如果我在连接时遇到问题,我通常会像您一样使用 IP 地址。但是...您尝试过服务器的 DNS 名称吗?
-
是的 - 我也遇到了同样的问题!
-
您运行的是什么版本的 SQL?它是“localDB”版本吗?
SELECT @@VERSION会很容易告诉你。 -
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
您是否要让他们连接到您的本地计算机 SQL 实例?
标签: c# asp.net sql-server connection-string sql-server-2012-express