Error connecting to shared server SQL database (IONOS)

huangapple go评论59阅读模式
英文:

Error connecting to shared server SQL database (IONOS)

问题

我正在尝试使用IONOS共享托管来托管我的网站。最初在运行我的应用程序时遇到了HTTP 500错误。我在我的网站的第一个数据库调用周围加了try/catch,并使用 return Content($"Database error:{ex.Message}"); 显示了错误。

这产生了下面的异常。我已经尝试了我能想到的一切方法来使这个连接工作。我对所使用的提供程序和在appsettings.json文件中正确识别它的方法很感兴趣。我的当前设置包含在代码块中。IONOS支持说他们无法提供帮助,并建议我在社区寻求帮助。

我已经成功地在他们的站点上创建了一个数据库,并将我的本地副本还原到了其中。我使用他们的工具验证了表和存储过程确实存在于他们站点上的我的数据库中。

异常:
> 数据库错误:在建立与SQL Server的连接时发生与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。请验证实例名称是否正确,并验证SQL Server配置为允许远程连接。
> (提供程序:SNI_PN11,错误:52 - 无法找到本地数据库运行时安装。请验证SQL Server Express是否已正确安装并且启用了本地数据库运行时功能。)

appsettings.json:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "IONOS": "Server=db953512847.hosting-data.io;Initial Catalog=dbxxxxxxxxx;Database=dbxxxxxxx;User ID=dboxxxxxxx;Password=xxxxxxxxxx;MultipleActiveResultSets=True;Persist Security Info=false",
    "ProviderName": "System.Data.SqlServer"
  }
}
英文:

I am trying to use IONOS shared hosting to host my site. Originally I was getting an HTTP 500 error when running my app. I put a try/catch around the first database call in my site, and displayed the error using return Content($"Database error:{ex.Message}" );

This produces the exception below. I have tried everything I can think of to make this connection work. I am curious about the provider being used and the proper way to identify it in the appsettings.json file. My current settings are included in the code block. IONOS support says they can't help and suggested that I post to the community for help.

I have successfully created a database on their site and have restored my local copy to it. I use their tool to verify that the tables and stored procedures are indeed in my database on their site.

Exception:
> Database error: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: SNI_PN11, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime
feature is enabled.)

appsettings.json:

    {
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "IONOS": "Server=db953512847.hosting-data.io;Initial Catalog=dbxxxxxxxxx;Database=dbxxxxxxx;User ID=dboxxxxxxx;Password=xxxxxxxxxx;MultipleActiveResultSets=True;Persist Security Info=false",
    "ProviderName": "System.Data.SqlServer"
  }
}

答案1

得分: 1

我最终解决了这个问题。这是凭证的问题。我在第一次访问数据库周围放置了try/catch,并能够看到错误并取得进展。

英文:

I eventually got this to work. It was credentials issue. I put try/catch around first database access and was able to see the error and make progress.

答案2

得分: 0

这意味着你试图连接到LocalDb,而不是尝试连接到你发布的连接字符串中的服务器。因此,你遇到的问题是配置问题、日志记录和可观察性问题,而不是SQL Server连接问题。

英文:

This "Unable to locate a Local Database Runtime installation."

means that you're trying to connect to LocalDb, which means that you're NOT trying to connect to the server in your posted connection string.

So you have a configuration problem and a logging and observability problem, not a SQL Server connectivity problem.

huangapple
  • 本文由 发表于 2023年3月9日 19:08:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75683767.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定