我在 C# 中使用 mysql 数据读取器时注意到一个奇怪的行为。 当我执行查询时,我得到数据,并且我可以在阅读器对象中看到相同的数据。 然而,在调试过程中,当我在这里停下一秒或几毫秒时,数据会从读取器中消失,并且显示“枚举没有产生结果”。 下面是我的代码。 我无法找到相同的解决方案。
public async Task<bool> SelectAsync(MySqlCommand command)
{
DbDataReader reader;
try
{
MySqlCommand cmd = command;
command.Connection = _connection;
reader = await cmd.ExecuteReaderAsync();
while (reader.Read())
{
// extracting fields from reader object code goes here
}
reader.Close();
return true;
}
catch (Exception ex)
{
//error log
_errorMessage = $"{ex}";
return false;
}
}
最佳答案
如果你想在 Debug模式或WATCH模式下查看对象的状态;将由数据库调用填充,您必须首先实现它。
关于c# - 数据从读取器对象 C#/MYSQL 中消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54385739/