在asp.net中使用mysql数据读取器时出错 [英] error using mysql data reader in asp.net

查看:158
本文介绍了在asp.net中使用mysql数据读取器时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用



I use

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









}



}



并且在

时出错(myDataReader.Read())



as







}

}

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

推荐答案

当您尝试发送到许多数据时可能会发生这种情况。您可以限制从数据库返回的行数(向SQL查询添加LIMIT子句)。
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).


检查sql数据连接是否打开..
Check sql data connection is opened or not..

这篇关于在asp.net中使用mysql数据读取器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆