private void LoadTaskHistorys() { using (MySqlConnection con = new MySqlConnection(Database.getConnection())) { MySqlCommand com = con.CreateCommand(); try { con.Open(); string sql = @"SELECT * FROM task_history " + "WHERE taskSeq='" + task.seq + "' " + "ORDER BY seq DESC"; com.CommandText = sql; MySqlDataReader reader = com.ExecuteReader(); while (reader.Read()) { TaskHistory taskHistory = new TaskHistory(); taskHistory.seq = System.Convert.ToInt32(reader["seq"]); taskHistory.content = reader["content"].ToString(); taskHistory.rgstDate = reader["rgstDate"].ToString(); AddListViewTaskHistoryItem(taskHistory); } } catch { MessageBox.Show("데이터베이스 연결오류"); } con.Close(); } }
private void AddListViewTaskHistoryItem(TaskHistory th) { ListViewItem item = new ListViewItem(th.content); item.SubItems.Add(th.rgstDate); historyList.Items.Add(item); }