我必須找到一種方法在C#中要做到這一點,如果可能的話...C#mysqlreader
我必須將文件夾列表(mysql表),併爲每個文件夾循環我實例化我必須做另一個查詢,但是當我這樣做時它說:「已經有一個與此連接關聯的開放DataReader」,並且我已經在mysqlreader循環中。
請注意,我已經簡化了代碼,只是爲了向您展示,事實是我必須在mysqlreader循環中執行查詢,並且由於它們在同一個連接上,所以看起來不可能?
MySqlConnection cnx = new MySqlConnection(connexionString);
cnx.Open();
MySqlCommand command= new MySqlCommand("SELECT * FROM folder WHERE folder_id = " + id, cnx);
MySqlDataReader reader= commande.ExecuteReader();
while (reader.Read())
{
this.folderList[this.folderList.Length] =
new CFolder(reader.GetInt32"folder_id"), cnx);
}
reader.Close();
cnx.Close();
內部連接的使用是否存在於「new CFolder(int)」調用這個相同函數的事實中? – Reddog 2010-06-10 16:45:52