如何从.NET 4连接到SQL Server 2000连接到、NET、SQL、Server

2023-09-07 16:46:27 作者:小优雅°

下面是我的连接字符串...

Here's my connection string...

Data Source=MYMACHINE\SERVER2000; Initial Catalog=MyDatabase; User Id=sa; Password=p;

下面是错误....

时出现与网络相关的或特定于实例的错误,而   建立SQL Server的连接。服务器未找到或   无法访问。验证实例名称是否正确,以及   SQL Server配置为允许远程连接。 (提供者:SQL   网络接口,error:26 - 错误定位服务器/实例   指定)

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)

我可以正常连接使用企业管理器。此外,我已经在SQL Server升级到Serivce Pack 4中。

I can connect fine with Enterprise Manager. Also I have upgraded the SQL Server to Serivce Pack 4.

任何想法的问题可能是什么?

Any ideas what the issue might be?

推荐答案

我建议使用一个.udl文件测试连接字符串。我已经回答过类似的问题here.创建连接后,您可以重命名文件的扩展名为.txt,打开它,然后复制并粘贴在工作连接字符串。

I'd suggest testing your connection string using a .UDL file. I've answered a similar question here. After creating your connection, you can rename the extension of the file to .txt, open it and then copy and paste the working connection string in.