public static bool Insert(string tabel, Dictionary <string, object> data) { var insert = false; var kolom = ""; var value = ""; var hitung = 1; foreach (var val in data) { if (hitung != data.Count) { kolom += val.Key + ","; value += "'" + SqlEscape(val.Value.ToString()) + "',"; } else { kolom += val.Key; value += "'" + SqlEscape(val.Value.ToString()) + "'"; } hitung++; } var query = "INSERT INTO " + tabel + " (" + kolom + ") VALUES (" + value + ")"; if (DbConn.ExecNonQuery(query) > 0) { insert = true; } return(insert); }
public void Ubah(string id, string stat) { Query = "update login set status='" + stat + "' where username='******';"; if (!(dbConn.ExecNonQuery(Query) > 0)) { throw new Exception("Gagal"); } }