我從SQL獲取數據並將其放入列表中。這就是我現在想,從SQL獲取數據並放入列表
public class Fruit //custom list
{
public string aID { get;set; } // can be more then 1
public string bID { get;set; } // only 2 but different aID
public string name { get;set; } // only 1 for selection of aID and bID
}
,這就是我如何獲得從SQL數據,
var Fruitee = new Fruit();
using (SqlConnection cn = new SqlConnection(CS()))
{
cn.Open();
SqlCommand sqlCommand= new SqlCommand("SELECT * FROM myTable", cn);
SqlDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read())
{
Fruitee.add(reader["aID"], reader["bID"],reader["name"]) // ??? not sure what to put here as add is not available
}
cn.Close();
}
表看起來是這樣的,
援助,競價名
**
- 問題
**
我堅持如何項添加到列表和也是它的最佳實踐?
「增加」不可用先生 – Mathematics
創建水果的清單: –