In last 2-3 days I am having problem with inserting data to postgres databse from Qt program I made.
I have made connection with the database, but when I try to insert data, the program sends me this message:
ERROR: syntax error at or near "("
LINE 1: EXECUTE ('thisIsSomeName', 4, '0000')
^
QPSQL: Unable to create query
Here is the code from Qt that insert the value.
QSqlQuery qsql;
qsql.prepare("INSERT INTO baza(Name, ID, Birth Date)"
"VALUES (?, ?, ?)");
qsql.bindValue(0, "thisIsSomeName");
qsql.bindValue(1, 4);
qsql.bindValue(2, "0000");
if (qsql.exec())
{
label->setText("all is good");
}
Can you please tell how to make this work. Thanks. Script of baza
CREATE TABLE baza
(
"Name" name NOT NULL DEFAULT 50,
"ID" integer NOT NULL,
"Birth Date" text DEFAULT 0,
CONSTRAINT baza_pkey PRIMARY KEY ("ID")
)
WITH (
OIDS=FALSE
);
ALTER TABLE baza OWNER TO postgres;
Nameand can you give the full table script of baza? it will be helpfulCREATE TABLE baza ( Name name NOT NULL DEFAULT 50, ID integer NOT NULL, Birth Date text DEFAULT 0, CONSTRAINT baza_pkey PRIMARY KEY ("ID") ) WITH ( OIDS=FALSE ); ALTER TABLE baza OWNER TO postgres;"forname,IDandBirth date