我有以下MySql命令
MySqlCommand binData = new MySqlCommand("SELECT binType, binColour from bin WHERE '"
+ sessionVarAddress +"' = address_addressID ", connect);
我想尝试执行此操作,并尝试如下:
foreach(DataRow in binData.ExecuteReader())
但这是不正确的,我该如何正确执行此命令?
答案 0 :(得分:1)
你可以执行它:
var reader = binData.ExecuteReader();
while (reader.Read())
{
// do whatever you need, access reader data as reader[i]
}
reader.Close();
有关详细信息,请参阅MySQL documentation。