0

I'd like to connect to a local instance of SQL Server on another machine within the same network, and am wondering if it's even possible.

For example, say we have Machine01 and Machine02, both on the same internal network. I have several IIS websites setup on Machine01. If I log onto Machine02 and query the URL of one of the websites on Machine01 in in internet browser (say http://Machine01:9000), the website will load just fine. This has me thinking that it might be possible to construct a connection string to access the local database on Machine01 from Machine02. Is this possible?

I have Allow remote connections to this server checked in SSMS.

I've tried this connection string:

Server=Machine01;trusted_connection=true;Database=MyDB;Persist Security Info=True
4

2 回答 2

1

您的连接字符串是正确的,因为 Server 是目标计算机名称,并且您尝试做的事情的前提肯定是正确的并且很有可能。

但是,请确保 Machine01 上的防火墙设置为允许 LAN 上来自 SQL Server 端口(默认为 1433)的入站流量。

此外,trusted_connection 位可能不起作用,具体取决于您如何设置用户。如果 Machine02 上的用户帐户是 Machine01 上的受信任用户帐户?如果有任何疑问,请在您的 Machine01 SQL 服务器上设置一个 SQL Server 用户帐户,确保您已启用 SQL 连接(服务器属性 -> 安全 -> SQL Server 和 Windows 身份验证模式),并传递 SQL 用户名和密码而是在连接字符串中...

于 2014-06-16T19:39:17.133 回答
0

You might try setting up a linked server, I find it to make the queries much easier. Here is some information on how to set it up.

于 2014-06-17T18:22:51.607 回答