SQL Azure +收到错误消息,即使设置了"MultipleActiveResultSets = True",也存在与此命令关联的打开的DataReader. [英] SQL Azure + Getting an error 'There is already an open DataReader associated with this Command..', even after setting ‘MultipleActiveResultSets=True’

查看:77
本文介绍了SQL Azure +收到错误消息,即使设置了"MultipleActiveResultSets = True",也存在与此命令关联的打开的DataReader.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在云上部署应用程序时遇到了一些问题.

We are facing some issues with the deployed version of our application on cloud.

我们的应用程序是带有ADO .NET实体框架的ASP.NET MVC 3项目.

Our application is an ASP.NET MVC 3 project with ADO .NET Entity Framework.

根据msdn博客,我们需要在我们正确完成的数据库连接字符串中添加参数"MultipleActiveResultSets = True"(对于具有SQL azure的Entity Framework).

According to the msdn blogs, we need to add the parameter ‘MultipleActiveResultSets=True’ (for Entity Framework with SQL azure) in our database connection string which we have rightly done.

在从我们的应用程序执行数据库查询时,我们得到以下异常:‘已经有一个与此Command关联的打开的DataReader,必须先关闭它.", 我想这与"MultipleActiveResultSets = True"属性非常相关.

We get the following exception while executing a database query from our application: ‘’There is already an open DataReader associated with this Command which must be closed first.", which I guess is very much related to the ‘MultipleActiveResultSets=True’ property.

该应用程序可以在本地环境中与我们本地部署的数据库以及SQL Azure数据库(在本地环境中)正常工作.

The application works fine on the local environment with our locally deployed database as well as using the SQL azure database (on local environment).

但是,当我们部署云应用程序时,会遇到上述错误.似乎没有从连接字符串中读取"MultipleActiveResultSets = True"属性.

But when we deploy our application of cloud we get the above mentioned error. It seems that ‘MultipleActiveResultSets=True’ property is not being read from the connection string.

我正在使用的连接字符串如下:

The connection string that I am using is as follows:

    <connectionStrings>
        <add name="#DBInstanceName#" connectionString="Data Source=tcp:#server#.database.windows.net,1433;Initial Catalog=#DBName#;User ID="UserName#@#server#;Password="#password#";MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>

我能够使用本地部署的应用程序中的上述连接字符串连接到SQL Azure数据库,没有任何例外.但是,当使用相同的连接字符串将相同的应用程序部署到云中时,会出现上述错误.

I am able to connect to SQL Azure database using the above connection string from the locally deployed application without any exceptions. But the same application when deployed on cloud using the same connection string gives me the above mentioned error.

您能帮我们解决这个问题吗?

Can you please help us fixing the same?

推荐答案

我遇到了同样的问题.我尝试在Web.config连接中设置"MultipleActiveResultSets = True"-没有结果. 最后,我通过直接在网站的Azure仪表板中手动编辑连接字符串来解决了问题-在配置"选项卡中,存在连接字符串"设置,您应在其中手动添加"MultipleActiveResultSets = True;".细绳. 这样做之后,我终于完成了MARS的工作.

I've just got the same issue. I has tried setting "MultipleActiveResultSets=True" in Web.config connection - no results. Finally I've resolved issue by manually editing Connection string directly at Azure Dashboard for the web site - in "Configure" tab there is "Connection strings" settings where you should manually add the "MultipleActiveResultSets=True;" string. After doing that I've got MARS worked finally.

这篇关于SQL Azure +收到错误消息,即使设置了"MultipleActiveResultSets = True",也存在与此命令关联的打开的DataReader.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆