MySQL Exception - Fatal Error Encountered During Data Read

半腔热情 提交于 2019-11-28 11:14:24
Adil

Between connection.Open(); and command.ExecuteNonQuery(); I just added two lines like this:

connection.Open();

MySqlCommand cmd = new MySqlCommand("set net_write_timeout=99999; set net_read_timeout=99999", connection); // Setting tiimeout on mysqlServer
cmd.ExecuteNonQuery();

int numOfRecordsUpdated = command.ExecuteNonQuery();

Problem Fixed :)

I believe there are buffer size constraints with the .NET connector when reading large datasets. I have worked around this problem by reading 5000 records at a time.

Or just simply:

cmd.CommandTimeout = 99999;

I have had similar sorts of issues with the .NET connector. The error may be speed related - C# may be trying to process the data faster than MySQL can keep up. I end up doing two things to remedy - 1. Add a sleep timer when a error occurs (or after processing a large section) so the system can "breathe" or 2. try to read again.

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