【问题标题】:connection string for SQL Server 2012 on same machine同一台机器上 SQL Server 2012 的连接字符串
【发布时间】:2023-03-15 18:25:02
【问题描述】:

我在一台服务器上运行 sql server 2012,我的网站在另一台服务器上运行。我总是使用这样的连接字符串来连接服务器:

connectionString="Data Source = xxx.xxx.xxx.xxx; Initial Catalog=MyDatabase; Integrated Security=false; User ID=MyUserName; Password=MyPassword"

但是现在当我将网站移动到与数据库相同的计算机时,我不确定我的连接字符串应该是什么样子,所以我只是更改了Data Source = "127.0.0.1" 并使用 localhost ip 连接到它。它工作正常,但有更好或更合适的方法吗?

谢谢

【问题讨论】:

    标签: sql sql-server string connection


    【解决方案1】:
    • 127.0.0.1
    • 本地主机
    • 。 (点表示本地主机)

    连接本地数据库一切正常。

    【讨论】:

    • 所以这3个没有区别,都是一样的?
    • 是的,它们都是一样的。
    【解决方案2】:

    connectionString="Data Source =.; Initial Catalog=MyDatabase; Integrated Security=false; User ID=MyUserName; Password=MyPassword"

    如果你使用“.”作为您的数据源,它意味着本地机器

    【讨论】:

    • 所以我所做的也是正确的,使用“。”没有区别。与 127.0.0.1 相比?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-11
    • 1970-01-01
    • 2012-06-25
    • 1970-01-01
    相关资源
    最近更新 更多