【发布时间】:2011-04-09 17:33:58
【问题描述】:
您好,我在阅读 MySqlDataReader 时遇到问题。我试图将while() 更改为if(),然后它就起作用了。所以我对while (Reader.Read()) 做错了。感谢您的回答。 (今天的另一个问题已解决,评论的人帮助了我xd)
using (MySqlCommand cmd = new MySqlCommand
("SELECT * FROM `citationer`", mysqlCon))
{
try
{
MySqlDataReader Reader = cmd.ExecuteReader();
while (Reader.Read()) // this part is wrong somehow
{
citationstexter.Add(Reader.GetString(loopReading)); // this works
loopReading++; // this works
}
Reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
【问题讨论】:
-
您能否提供异常详细信息。我觉得很好。