我正在尝试从MySql数据库表中检索数据
Date, Price
5/5/1998 93.5$
10/5/1998 97.6$
并将它们存储在ArrayList或List中,以便进行一些统计计算。
string constring = "datasource=localhost;port=3306;username=root;password=;";
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlCommand cmdDataBase = new MySqlCommand("Select Date,AnnualPrice from db_og.historicprices;", conDataBase);
MySqlDataAdapter mySqlDA = new MySqlDataAdapter(cmdDataBase);
DataTable dt = new DataTable();
mySqlDA.Fill(dt);
List<string> data = new List<string>();
if (dt.Rows.Count > 0)
{
foreach (DataRow drow in dt.Rows)
data.Add(drow["Date"].ToString());
}