gpt4 book ai didi

c# - SQL Server Azure "Login failed for User"

转载 作者:行者123 更新时间:2023-12-04 02:06:36 27 4
gpt4 key购买 nike

我正在使用以下代码对我的 Azure 数据库执行 SQL 命令。我在 ASP.NET MVC 操作方法中执行了两次调用。第一个调用从表 A 中删除,第二个调用从表 B 中删除。

  using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConnectionString))
{
using (System.Data.SqlClient.SqlCommand command = conn.CreateCommand())
{
conn.Open();
command.CommandText = statement;
command.ExecuteNonQuery();
}
}

无论出于什么原因,当我第二次调用此代码时(我将其放在 Helper 服务类中),它会出现以下 Azure 错误。

Additional information: Login failed for user 'MyUser'.

是否有什么事情我做得不正确,但可能没有关闭连接,或者 Azure 遇到了问题?

最佳答案

您需要允许您的 IP 地址访问 Azure 数据库。单击配置并添加您的 IP。

关于c# - SQL Server Azure "Login failed for User",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24510804/

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