相关连接:http://stackoverflow.com/questions/11131429/fatal-error-encountered-during-data-read
代码:
/// <summary>
/// 执行SQL,返回DataReader对象
/// </summary>
/// <param name="cmdText"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public System.Data.IDataReader ExcuteDataReader(string cmdText, System.Collections.IEnumerable parameters)
{
IDataReader dataReader = null;
IDbConnection connection = CreateDbConnection();
//Command
IDbCommand command = new MySqlCommand(cmdText);
IDbCommand commandTimeout = new MySqlCommand("set net_write_timeout=99999;set net_read_timeout=99999");
commandTimeout.Connection = connection;
commandTimeout.ExecuteNonQuery();
command.Connection = connection;
PreDbCommand(command, parameters);
//
dataReader = command.ExecuteReader(CommandBehavior.CloseConnection);
//创建Command
return dataReader;
}