//返回数据
private List
///
/// 获取hk_data_5s数据
///
internal void Fill() {
SqlConnection conn = null;
SqlCommand cmd = null;
SqlDataAdapter SqlDataAdapter =null;
DataTable dataTable = null;
try {
//MySQL连接
//从配置文件读取
conn = new SqlConnection(_connStr);
conn.Open();
cmd = new SqlCommand("SELECT * FROM _data;", conn);
SqlDataAdapter = new SqlDataAdapter(cmd);
dataTable = new DataTable();
SqlDataAdapter.Fill(dataTable);
DataRow row;
List
Entity entity;
for (int i = 0; i < dataTable.Rows.Count; i++) {
row = dataTable.Rows[i];
entity = new Entity();
entity.symbol = row["symbol"].ToString();
entity.desp = row["desp"].ToString();
entitys.Add(entity);
}
_data = entitys;
}
catch (Exception ex) {
Util.Log(ex.Message, null);
}
finally {
if (SqlDataAdapter != null) {
SqlDataAdapter.Dispose();
}
if (cmd != null) {
cmd.Dispose();
}
if (conn != null) {
conn.Close();
conn = null;
}
}
}
///
/// 行情数据对应的实体
///
public class Entity {
public string symbol;
public string desp;
}