使用.NET连接MSDE2000时的连接问题

发布于 2024-12-04 13:15:40 字数 993 浏览 1 评论 0原文

我有一个奇怪的问题。我正在尝试从 C# (.Net 4.0) 连接到 Microsoft SQL 服务器。服务器正在运行 MSDE2000(8.00.194)。当我连接时,我收到以下消息:

System.Data.SqlClient.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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)

我的连接字符串如下所示,(是的,我使用的是空白密码): “用户 ID=sa;密码=;数据源=192.168.0.100\?,1433;Trusted_Connection=false;初始目录=DATABASE1;”

我尝试更改连接字符串中的几乎所有内容以使其正常工作,但没有成功。我什至尝试过使用 OleDBConnection 而不是 SqlConnection 但没有成功。

奇怪的是,当我通过 Microsoft Management Studio 连接时,我能够连接并查看所有内容。但是我发送的每个命令之间都会断开连接,并且必须重新连接。

有谁知道问题可能是什么或者我应该从哪里开始寻找问题?

编辑:我可能会补充一点,我尝试通过端口 1433 远程登录到计算机,但收到“连接被主机关闭”。问题是我无权访问计算机,因此无法检查防火墙设置,但 Management Studio 的连接方式是否与 .Net 相同?

I have a strange problem. I'm trying to connect to a Microsoft SQL server from C# (.Net 4.0). The server is running MSDE2000(8.00.194). When I connect I get the following message:

System.Data.SqlClient.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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)

My connectionstring looks like this,(yes i'm using a blank password):
"User Id=sa;Password=;Data Source=192.168.0.100\?,1433;Trusted_Connection=false;Initial Catalog=DATABASE1;"

I've tried changing pretty much everything in the connection string to get it to work without success. I've even tried doing an OleDBConnection instead of the SqlConnection but without success.

The strange thing is that when I connect through Microsoft Management Studio I'm able to connect and see everything. But I get disconnected between every command I send and have to reconnect.

Does anyone know what the problem might be or where I should start looking to find the problem?

Edit: I might add that I tried to telnet to the machine on port 1433 but got "Connection closed by host". The thing is that I do not have access to the computer so I can't check firewall settings but isn't the Management Studio connecting the same way as .Net do?

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

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

发布评论

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

评论(1

極樂鬼 2024-12-11 13:15:41

您确定此类 MSDE 2000 的实例已启动并正在运行吗?您可以使用 SQL Management Studio 远程连接到该实例吗?谁安装了该实例?默认情况下,tcp 连接在默认安装中被禁用,这在 SQL Server 2005 Express 中仍然发生(不确定 2008 版本),因此除非安装它的人已正确配置它或知道如何设置它,否则您可能会缺少一些要启用的协议。

该实例在该机器上本地可用吗?

检查这里的默认连接字符串,我也怀疑?是有效的实例名称,如果您知道实例名称,则应指定它,

http://connectionstrings.com/ sql-server#p1

Are you sure the instance of such MSDE 2000 is up and running? can you connect to that instance remotely with your SQL Management Studio? Who has installed that instance? by default tcp connections are disabled in a default install, this still happened also in SQL Server 2005 Express (not sure about the 2008 version) so unless the guy who installed it has configured it properly or knew how to set it up, you could be missing some protocols to be enabled.

is that instance available locally on that machine?

check here for default connection strings, I also doubt that ? is a valid instance name and if you know the instance name you should specify it,

http://connectionstrings.com/sql-server#p1

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