【问题标题】:Can't acces SQL Server Express Database in IIS server无法访问 IIS 服务器中的 SQL Server Express 数据库
【发布时间】:2018-05-26 05:17:59
【问题描述】:

我在本地有一个应用程序 ASP.net MVC。我正在使用 VisualStudio 2017 和 IIS Express 和 SQL Server Express。 我试图将我的项目放在我计算机上的本地 IIS 上。我的应用程序可以在我的浏览器上执行,但由于我的代码在 IIS 上,我无法使用我的 SQL Server Express 发出一些请求。 我认为 SQL Server Express 需要一些参数,但我没有找到。

我的连接字符串是:

this.Database.Connection.ConnectionString = "Server=" + NameServer + "; Database=" + NameDatabase + "; Integrated Security = true";

我用的是localDB Sql Server Express 不知道是不是有问题 如果你有什么想法?

【问题讨论】:

  • 你能给我们一些代码吗?还有你使用的connectionString?
  • 暂时,仅用于测试,将您的 windows 帐户设置为运行应用程序池的帐户,看看会发生什么。同时,将您收到的异常详细信息添加到您的问题中作为编辑。

标签: c# asp.net sql-server iis


【解决方案1】:

你遇到了什么错误?

您是否尝试过将连接字符串直接从 SQL Server 复制粘贴到您的 Web.config 文件中?此外,由于您处于测试阶段,请确保您尝试登录的用户存在于 SQL 服务器中。

确保连接字符串存在于 IIS 上 Web 应用的“功能”选项卡中。

尝试用

替换您的连接字符串
this.Database.Connection.ConnectionString = "Server=" + NameServer + "; Database=" + NameDatabase + "; Integrated Security = SSPI";

SSPI 和 true 可能看起来相似,但它们并不相同,see this answer for a more detailed explanation.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多