Пример #1
0
        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);
        }
Пример #2
0
        public void Ubah(string id, string stat)
        {
            Query = "update login set status='" + stat + "' where username='******';";

            if (!(dbConn.ExecNonQuery(Query) > 0))
            {
                throw new Exception("Gagal");
            }
        }