public int Delete(string where, string tabla) { NpgsqlConnection conexion = new NpgsqlConnection(MetodosDatos.cadenaConexion); NpgsqlCommand comando = new NpgsqlCommand("DELETE from " + tabla + " where " + where, conexion); return(MetodosDatos.EjecutarComando(comando)); }
public int Insert(string datos, string columnas, string tipoDatos, string funcion) { datos = datos.Replace("''", "null"); NpgsqlCommand comando = MetodosDatos.CrearComandoProc(funcion); if (datos.Contains("?")) { string[] vector1 = Vector(datos); string[] vector2 = Vector(columnas); string[] vector3 = Vector(tipoDatos); for (int i = 0; i < vector1.Length; i++) { comando.Parameters.Add(new NpgsqlParameter(vector2[i], vector3[i])); comando.Parameters[i].Value = vector1[i]; } } else { comando.Parameters.Add(new NpgsqlParameter(columnas, tipoDatos)); comando.Parameters[0].Value = datos; } return(MetodosDatos.EjecutarComando(comando)); }
public int Update(string tabla, string campo, string where) { NpgsqlConnection conexion = new NpgsqlConnection(MetodosDatos.cadenaConexion); NpgsqlCommand _comando = new NpgsqlCommand("UPDATE " + tabla + " SET " + campo + " WHERE " + where, conexion); return(MetodosDatos.EjecutarComando(_comando)); }
public int Insert(string datos, string columnas, string tabla) { datos = datos.Replace("''", "null"); NpgsqlConnection conexion = new NpgsqlConnection(MetodosDatos.cadenaConexion); NpgsqlCommand comando = new NpgsqlCommand("insert into " + tabla + " (" + columnas + ") values (" + datos + ")", conexion); return(MetodosDatos.EjecutarComando(comando)); }