好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

c# – 连接到其他PC上的SQL Server

我试图让我的程序,使用SQL Server,在另一台机器上可用.我知道该机器需要安装SQL Server客户端才能工作,但我想知道我的ConnectionString是否可以在我自己的PC之外工作.

我是否需要将数据库附加到项目中?如果是这样,我怎么能这样做?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\BENESQL;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=123qwe;" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>
您的数据源必须包含其他PC名称或IP地址,因此不是:

Data Source=.\BENESQL

你需要这样的东西:

Data Source=123.123.123.123\BENESQL

此外,您需要记住向防火墙等添加例外.

查看更多关于c# – 连接到其他PC上的SQL Server的详细内容...

  阅读:48次