Mysql connector - MultipleActiveResultSets issue

大城市里の小女人 提交于 2019-11-28 05:20:45

问题


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 a c# application for myself(Personal use). Im running the latest MySQL connector library from mysql.com

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; . When this is included in my SQLConnection string the MySQL library is unable to connect. View the pic below to view my findings

full image: http://i62.tinypic.com/25a57p1.png

When MultipleActiveResultSets=True; is removed from the connection string, I get this result

full image: 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.

If anyone knows why this is failing, then please suggest your fix.

My local MySQL server version: 5.6.17


回答1:


I assume MySql connector doesn't support MARS (Multiple active result sets). In such case you cannot use it at more than one place at the same time.




回答2:


The problem is not solved but I have found a work around.

I removed 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. 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.




回答3:


One more option which can cause a little performance hit but can be used as quick fix is to open one more connection to the database for the second reader and close it when you are done.



来源:https://stackoverflow.com/questions/25953560/mysql-connector-multipleactiveresultsets-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!