public static void initQuery(List <string> sqlKeyList, List <string> sqlValueList) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = MjSql.createSqlConnection(); cmd.CommandText = "select sqlKey from SQLQuery"; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { sqlKeyList.Add(reader["sqlKey"] as string); } reader.Close(); cmd.CommandText = "select sqlValue from SQLQuery"; reader = cmd.ExecuteReader(); while (reader.Read()) { sqlValueList.Add(reader["sqlValue"] as string); } reader.Close(); } Program.SQLDic.Clear(); for (int i = 0; i < sqlKeyList.Count; i++) { Program.SQLDic.Add(sqlKeyList[i], sqlValueList[i]); } }
private void btnKeyOk_Click(object sender, EventArgs e) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = MjSql.createSqlConnection(); cmd.CommandText = $"Update SQLQuery set sqlKey ='{tbKey.Text}' where sqlKey ='{Program.sqlKey}'"; cmd.ExecuteNonQuery(); } }
private void btnSave_Click(object sender, EventArgs e) { if (tbKey.Text == string.Empty || tbValue.Text == string.Empty) { MessageBox.Show("빈 값이 있습니다."); return; } //체크박스가 활성화 되어야만 진행가능 if (bCheck == true) { MessageBox.Show("Key 값이 중복됩니다."); return; } using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = MjSql.createSqlConnection(); cmd.CommandText = $"insert into SQLQuery values((select count(sequence) from SQLQuery)+1 ,'{tbKey.Text}','{tbValue.Text}')"; cmd.ExecuteNonQuery(); } }