gpt4 book ai didi

sql-server - 如何修复 "Server name cannot be determined. It must appear as the first segment of the server' s dns 名称 (servername.database.windows.net)"

转载 作者:行者123 更新时间:2023-12-05 07:23:52 26 4
gpt4 key购买 nike

我在 Visual Studio 2017 .NET Framework 4.7.1 中有一个具有身份的 Web 应用程序,它连接到 azure sql server 数据库。提交登录表单后出现错误。异常消息是:“无法确定服务器名称。它必须显示为服务器 dns 名称 (servername.database.windows.net) 的第一段。某些库不发送服务器名称,在这种情况下,服务器名称必须包含在用户名 (username@servername)。此外,如果使用两种格式,服务器名称必须匹配。"

该错误仅出现在 Web 服务器(Azure 应用程序服务)中。当我在本地(localhost)运行它时,它工作正常。

我做了错误消息提示的操作,但是没有成功。我对此进行了搜索,但是我发现的建议或解决方案都不起作用。

如果我删除登录内容,应用程序就能够连接并工作,因此问题似乎是我用来连接到身份表的连接字符串。

我在 web.config 中尝试过此连接字符串,但没有一个起作用:

1.添加名称=“DefaultConnection”connectionString =“服务器= tcp:myServer.database.windows.net,1433;初始目录= myDatabase;持久安全信息= False;用户ID = myUser@myServer;密码= myPassword;MultipleActiveResultSets = False;加密=True;TrustServerCertificate=False"providerName="System.Data.SqlClient"

2.添加名称 =“DefaultConnection”connectionString =“数据源 = myServer.database.windows.net;初始目录 = myDatabase;集成安全性 = False;用户 ID = myUser;密码 = myPassword;MultipleActiveResultSets = True”providerName =“System.Data. SQLClient”

最佳答案

首先,您是否将允许访问 Azrue 服务设置为开启?

请在门户上检查您的 Azrue SQL 数据库防火墙设置:

enter image description here

其次,获取正确的连接字符串: enter image description here

其他请参见:Troubleshooting connectivity issues with Microsoft Azure SQL Databaseenter image description here

希望这能有所帮助。

关于sql-server - 如何修复 "Server name cannot be determined. It must appear as the first segment of the server' s dns 名称 (servername.database.windows.net)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55732863/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com