【问题标题】:How do I connect to SQL Server using Remote Desktop如何使用远程桌面连接到 SQL Server
【发布时间】:2026-01-01 02:40:02
【问题描述】:

我正在尝试使用 C# 应用程序连接到远程 PC 上的 SQL Server Express。当我在本地 PC 上将应用程序运行到本地服务器时,它可以正常工作。当我使用远程桌面连接到客户端 PC 并运行应用程序时(我将连接字符串更改为本地服务器地址),我收到错误:

错误 26:错误定位指定的服务器/实例**

问题可能出在我的连接字符串中吗?

我已经尝试对我的连接字符串进行多次更改(参见下面的代码),甚至尝试了整个 UDP 连接 1433 TCP/IP 端口更改。

SqlConnection sqlcon = new SqlConnection(@"Data Source=1FEPINMA02\SQLEXPRESS; Initial Catalog=Indigo; User Id=IndigoUser; Password=IndigoUser ;User Instance=False;");

//SqlConnection sqlcon = new SqlConnection(@"Data Source=DAVIDBRITS\SQLEXPRESS;Initial Catalog=Indigo;Integrated Security=True "); // <---------- This is commented out because we tried this also.

【问题讨论】:

  • 我会先尝试连接sql management studio。
  • @ibram 感谢您的回复。我可以通过 SQL Management Studio 进行连接。
  • @MitchWheat 谢谢。如果可行,我会尝试并更新。
  • 防火墙已设置为允许 SQL Server 端口?

标签: c# sql-server database sql-server-express


【解决方案1】:
sqlconstringx = "Data Source=ipaddress;Initial Catalog=MyDatabase; User ID=MyUsername;password=MyPassword;";

请尝试。

确保您可以 ping 服务器

【讨论】:

  • 它是连接到一个实例,而不是默认端口,所以你的答案应该是ipaddress\SQLEXPRESS
最近更新 更多