I have this:
NpgsqlConnection c = new NpgsqlConnection(conx.getConexion());
c.Open();
NpgsqlDataAdapter da = new NpgsqlDataAdapter("Insert into \"Marca\" (\"NombreMarca\") values ('" + cbMarca.Text + "')", c);
c.Close();
And the table is:
CREATE SEQUENCE idmarca
INCREMENT 1
MINVALUE 1
MAXVALUE 2147483647
START 10
CACHE 1;
CREATE TABLE "Marca"
( "idMarca" integer NOT NULL DEFAULT nextval('idmarca'::regclass),
"NombreMarca" character varying(100) NOT NULL,
CONSTRAINT "PKMarca" PRIMARY KEY ("idMarca" ),
CONSTRAINT "UNombreMarca" UNIQUE ("NombreMarca" )
);
The problem is, when I try to insert into the table, for some reason nothing happens. That's on a try - catch, so no exceptions are being generated from the query.
cbMarca is a combobox. The connection with the database is already tested.
Also, this works:
cbMarcaB.Items.Clear();
DataTable dt = cons.Select("Select \"NombreMarca\" From \"Marca\" Order by \"NombreMarca\"");
for (int i = 0; i < dt.Rows.Count; i++)
{
cbMarcaB.Items.Add(dt.Rows[i]["NombreMarca"]);
}
So I don't know what the problem is ...