Hi,
I see this line: cmd.CommandText = "set net_write_timeout=" + Timeout.Infinite + "; set net_read_timeout=" + Timeout.Infinite + "; Set Character_Set_Connection='UTF8'; set Collation_connection='utf8_general_ci';";
System.Threading.Timeout.Infinite is wrong, -1 is not valid timeout value.
From the documentation:
http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_net_write_timeout
The min value of these variables is 1, no mention of max value, but...
I checked at the server code 5.6.x and found that the biggest value allowed for these net_xx_timeout variables is 31536000.
I tested it and is set correctly with the queries:
set net_write_timeout = 31536000
show variables like 'net_write_timeout'
As a reference in the server Source:
sql\sys_vars.c
static Sys_var_ulong Sys_net_write_timeout(
"net_write_timeout",
"Number of seconds to wait for a block to be written to a connection "
"before aborting the write",
SESSION_VAR(net_write_timeout), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, LONG_TIMEOUT), DEFAULT(NET_WRITE_TIMEOUT), BLOCK_SIZE(1),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(fix_net_write_timeout));
sql\sql_const.h
#define LONG_TIMEOUT ((ulong) 3600L*24L*365L)
(So if you need a really big value, use 31536000).
But all this is assuming the -1 in timeout is the culprit, please let me know if this fixes your problem.