Ricevo i dati da SQL e li inserisco nell'elenco. ecco quello che sto provando ora,Ottenere dati da SQL e inserire un elenco
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
}
e questo è come sto ottenendo i dati da 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();
}
tabella assomiglia a questo,
soccorso, BID, nome
**
- Problema
**
sono bloccato come aggiungere elementi da elencare e è anche migliori pratiche?
"aggiungere" non è disponibile signore – Mathematics
Creare un elenco di frutti: –