I need to populate a generic List of string with the result set of a single-column query. I've got this code:
private List<String> _mammalsList;
. . .
private void LoadMammalStringList()
{
_mammalsList = new List<string>();
using (SqlConnection con = new SqlConnection(PlatypusUtils.DuckbillConnStr))
{
using (SqlCommand cmd = new SqlCommand(PlatypusUtils.SelectMammalIdQuery, con))
{
cmd.CommandType = CommandType.Text;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
// Now that the data is in dt, how can I pull it out of there and put it into the List<String>?
}
}
}
}
...but don't know just how to access the data set returned. How can I do that?