如何使用 IP 地址远程连接到 Sql Server 2008?

发布于 2024-07-25 06:43:17 字数 790 浏览 12 评论 0原文

当我发布项目时,客户端需要能够设置初始配置,其中一部分是 Sql 数据库连接。 我的系统上运行着一个 Sql Server 2008 实例 (MSSQLSERVER2008) 以及 SQLEXPRESS2005。 我试图在本地使用以下连接字符串只是为了看看这是否有效,但我无法让它工作:

ConnectionString = {Data Source=127.0.0.1;Initial Catalog=DCOMProductionsDesktop;Integrated Security=False;User ID=DCOMProductionsDesktopService;Password=;Network Library=dbmssocn}

我得到的错误是通常的“目标计算机主动拒绝连接”。

*没有任何防火墙运行,而且它在网络内部 *TCP/IP 协议已启用 *远程连接已启用并允许

所以,我很困惑。

编辑

我将连接字符串的数据源更改为:

DataSource=192.168.0.2\MSSQLSERVER2008 on my WinXP VM (for testing remotely)

现在,这确实有效。 但是,当我在互联网上部署它时,相同的连接字符串是否适用于使用域名的网络外部的客户端,例如:

DataSource=desktop.dcomproductions.com\MSSQLSERVER2008

或者我需要做一些不同的事情?

When I publish my project clients will need to be able to setup the initial configuration, and part of that is the Sql Database Connection. I have an instance of Sql Server 2008 running on my system (MSSQLSERVER2008) as well as SQLEXPRESS2005. I am trying to use the following connection string locally just to see if this works, and I can't get it to work:

ConnectionString = {Data Source=127.0.0.1;Initial Catalog=DCOMProductionsDesktop;Integrated Security=False;User ID=DCOMProductionsDesktopService;Password=;Network Library=dbmssocn}

The error I get is the usual "The target machine actively refused the connection".

*There isn't any firewalls running, and its inside the network anyway
*TCP/IP Protocols are enabled
*Remote Connections are enabled and permitted

So, I'm stumped.

Edit

I changed the connection string's data source to:

DataSource=192.168.0.2\MSSQLSERVER2008 on my WinXP VM (for testing remotely)

Now, this did work. But when I deploy this across the internet, will that same connection string work for clients outside my network using a domain name such as:

DataSource=desktop.dcomproductions.com\MSSQLSERVER2008

Or will I need to do something different?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陪你到最终 2024-08-01 06:43:17

只要“desktop.dcomproducts.com”或其他任何内容解析为正确的 IP 地址,它就可以工作。 因此,应该在公共或私有 DNS 上正确设置该名称。

另外,请确保它解析为公共/外部 IP 地址,除非您的客户端脚本与 SQL 服务器位于同一网络中。

我以为我将其发布为答案,而不是评论:)

It will work, as long as "desktop.dcomproductions.com" or whatever, resolves to the proper IP address. So that name should be set up either on the public or private DNS properly.

Also, make sure it resolves to a public/external IP address, unless your client's scripts are going to be within the same network as the SQL server.

Thought I post it as an answer, instead of comments :)

橘虞初梦 2024-08-01 06:43:17

我已经有一段时间没有使用除命名管道之外的任何东西来连接到 SQL Server 实例了,因此这可能不相关,但请尝试将数据源更改为服务器。

正如我所说,它们可能是同义词,已经有一段时间了。

此外,即使您使用 IP 地址,您也没有指定要连接的 sql server 实例,这也可能会导致问题

It's been a while sice I used anything but Named Pipes to connect to a sql server instance so this may not be relevent but try changong Data Source to Server.

They may be synonyms, as I said, it's been a while.

Also, even if you are using an IP address, you aren't specificying an instance of sql server to connect to, that may also be causing issues

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文