I use
if (myDataReader.HasRows)
{
while (myDataReader.Read())
{
}
}
and get error at
while (myDataReader.Read())
as
Server Error in '/' Application.
An existing connection was forcibly closed by the remote host
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6508791
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +130
[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
MySql.Data.Common.MyNetworkStream.HandleOrRethrowException(Exception e) +92
MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count) +62
MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) +127
System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count) +262
MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count) +42
MySql.Data.MySqlClient.MySqlStream.LoadPacket() +194
[MySqlException (0x80004005): Reading from the stream has failed.]
MySql.Data.MySqlClient.MySqlStream.LoadPacket() +272
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +32
MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns) +18
MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns) +14
MySql.Data.MySqlClient.ResultSet.GetNextRow() +34
MySql.Data.MySqlClient.ResultSet.NextRow(CommandBehavior behavior) +130
MySql.Data.MySqlClient.MySqlDataReader.Read() +62
[MySqlException (0x80004005): Fatal error encountered during data read.]
MySql.Data.MySqlClient.MySqlDataReader.Read() +180