简体   繁体   English

Mysql连接器 - MultipleActiveResultSets问题

[英]Mysql connector - MultipleActiveResultSets issue

First off, I have spent hours looking for a fix - maybe I just need another pair of eyes on this problem. 首先,我花了几个小时寻找修复 - 也许我只需要另外一双眼睛来解决这个问题。

I'm currently coding ac# application for myself(Personal use). 我正在为自己编写ac#应用程序(个人使用)。 Im running the latest MySQL connector library from mysql.com 我从mysql.com运行最新的MySQL连接器库

My connection string is 我的连接字符串是

public string SQLConnection = "Server=localhost;Database=data;Uid=root;Pwd=ascent;charset=utf8;MultipleActiveResultSets=True;";

My issue is regarding MultipleActiveResultSets=True; 我的问题是关于MultipleActiveResultSets=True; . When this is included in my SQLConnection string the MySQL library is unable to connect. 当它包含在我的SQLConnection字符串中时,MySQL库无法连接。 View the pic below to view my findings 查看下面的图片以查看我的发现

http://i62.tinypic.com/25a57p1.png full image: http://i62.tinypic.com/25a57p1.png http://i62.tinypic.com/25a57p1.png 完整图片: http//i62.tinypic.com/25a57p1.png

When MultipleActiveResultSets=True; MultipleActiveResultSets=True; is removed from the connection string, I get this result 从连接字符串中删除,我得到了这个结果

http://i58.tinypic.com/2useaom.png full image: http://i58.tinypic.com/2useaom.png http://i58.tinypic.com/2useaom.png 完整图片: http//i58.tinypic.com/2useaom.png

I get a successful connection. 我获得了成功的联系。

The reason for MultipleActiveResultSets is because I'm using 2 MySqlDataReader at the same time - This however can't be changed. MultipleActiveResultSets的原因是因为我同时使用了2个MySqlDataReader - 但是无法更改。

If anyone knows why this is failing, then please suggest your fix. 如果有人知道为什么会失败,那么请建议您的修复。

My local MySQL server version: 5.6.17 我的本地MySQL服务器版本:5.6.17

I assume MySql connector doesn't support MARS (Multiple active result sets). 我假设MySql连接器不支持MARS(多个活动结果集)。 In such case you cannot use it at more than one place at the same time. 在这种情况下,您不能同时在多个地方使用它。

The problem is not solved but I have found a work around. 问题没有解决,但我找到了解决方法。

I removed MultipleActiveResultSets=True; 我删除了MultipleActiveResultSets=True; from the connection string. 来自连接字符串。 I then created a list where I saved the data from MySqlDataReader, I then closed the reader and reopen a new one which then I got the rest of the data from the database. 然后我创建了一个列表,我从MySqlDataReader中保存了数据,然后我关闭了读取器并重新打开了一个新的,然后我从数据库中获取了其余的数据。 Then simply merged the results together in the list. 然后只需将结果合并到列表中。

So yeah, a temp fix. 所以,是的,临时修复。

If someone knows the proper fix then please comment, otherwise I will be using my temp fix. 如果有人知道正确的修复,那么请评论,否则我将使用我的临时修复。

Thanks guys. 多谢你们。

另一个可以导致性能下降但可以用作快速修复的选项是为第二个读取器再打开一个数据库连接,并在完成后将其关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM