Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use

SQL
if (myDataReader.HasRows)
      {
          while (myDataReader.Read())
          {




}

}

and get error at
while (myDataReader.Read())

as

CSS
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




VB
[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
Posted

That can happen when you try to send to many data. You could limit the number of rows returned from the database (add a LIMIT clause to your SQL query).
 
Share this answer
 
Check sql data connection is opened or not..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900