I am using the following code to perform SQL commands to my azure DB. The I do two calls inside my ASP.NET MVC action method. One to delete from Table A, and the second call to delete from Table B.
我使用下面的代码对我的azure DB执行SQL命令。我在我的ASP中做两个调用。净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();
}
}
For whatever reason when I make the second call to this code (I have it in a Helper service class, it bombs with the following Azure error.
无论出于什么原因,当我第二次调用此代码时(我在Helper服务类中有它),它会产生以下Azure错误。
Additional information: Login failed for user 'MyUser'.
Is there something I'm not doing correctly but not perhaps closing a connection or something that Azure is having issues with this?
是否有一些事情我做得不正确,但可能没有关闭连接,或者Azure对此有问题?
3 个解决方案
#1
4
You need allow your IP Address to access azure database. click in configure and add your IP.
您需要允许您的IP地址访问azure数据库。单击configure并添加您的IP。
#2
1
I just needed add to the connection string
我只需要添加到连接字符串
Persist Security Info=False;
#3
0
when you publish your project into azure from visual studio, there is a 'settings' tab on the left.
当您将项目从visual studio发布到azure时,在左边有一个“设置”选项卡。
go to the settings. it will show you the connection string that you're using in the web.config.
去设置。它将显示在web.config中使用的连接字符串。
what worked for me is I unchecked the check box that says 'Use this connection string at runtime (update destination web.config)' and everything went well for me.
对我有效的是,我没有选中“在运行时使用此连接字符串(更新目标web.config)”的复选框,一切都很顺利。
#1
4
You need allow your IP Address to access azure database. click in configure and add your IP.
您需要允许您的IP地址访问azure数据库。单击configure并添加您的IP。
#2
1
I just needed add to the connection string
我只需要添加到连接字符串
Persist Security Info=False;
#3
0
when you publish your project into azure from visual studio, there is a 'settings' tab on the left.
当您将项目从visual studio发布到azure时,在左边有一个“设置”选项卡。
go to the settings. it will show you the connection string that you're using in the web.config.
去设置。它将显示在web.config中使用的连接字符串。
what worked for me is I unchecked the check box that says 'Use this connection string at runtime (update destination web.config)' and everything went well for me.
对我有效的是,我没有选中“在运行时使用此连接字符串(更新目标web.config)”的复选框,一切都很顺利。