public static int UpdateLine(string tabela, List <string> campos, List <string> valores, string filtro) { string query = "UPDATE " + tabela + " SET "; string temp1, temp2, s; while (campos.Count > 0) { temp1 = campos.First(); temp2 = valores.First(); query += temp1 + "="; if (HelperBd.VerificaInt(temp2)) //na verdade eu tenho que verificar o Controller e o tipo do campo atual { query += temp2; } else { if (HelperBd.VerificaBool(temp2, out s)) { query += s; } else { query += "'"; query += HelperBd.SanitizaString(temp2); query += "'"; } } campos.RemoveAt(0); valores.RemoveAt(0); if (campos.Count > 0) { query += ", "; } } if (filtro != "") { query += " WHERE " + filtro; } return(EnviaComando(query)); }
public static int InsereLinha(string tabela, List <string> campos, List <string> valores) { string s; string query = "INSERT INTO " + tabela + " ("; foreach (string item in campos) { query += item; query += ", "; } query = query.Remove(query.Length - 2); query += ") VALUES("; foreach (string item in valores) { if (HelperBd.VerificaInt(item)) //na verdade eu tenho que verificar o Controller e o tipo do campo atual { query += item; } else { if (HelperBd.VerificaBool(item, out s)) { query += s; } else { query += "'"; query += HelperBd.SanitizaString(item); query += "'"; } } query += ","; } query = query.Remove(query.Length - 1); query += ")"; return(EnviaComando(query)); }