eleanor
7th October 2007, 10:24
Hi. I'm using MySQL to write/read from the Mysql database.
I'm using QTableView to represent tables on the screen.
The problem is when the table is shown, and if I edit it manually, then I want to save the changes and I don't know how.
The second problem is:
void dbWindow::add_changes_kraj() {
QSqlQuery query;
QString table_name = "kraj";
//we use NULL because this is not php, and it will auto increment on it's own
query.prepare("INSERT INTO :table (id,ime,postna_st) VALUES(NULL,:ime,:postna_st)");
query.bindValue(":table",table_name);
query.bindValue(":ime",edit_ime->text());
query.bindValue(":postna_st",edit_postna_st->text());
query.exec();
//query.exec("insert into kraj values(NULL,'Town','4532')");
emit close();
}
- what is commented (query.exec("insert into kraj values(NULL,'Postojna','4532')");) works perfectly, but the other lines don't (which is the same...and I need to make them work).
Any idea?
I'm using QTableView to represent tables on the screen.
The problem is when the table is shown, and if I edit it manually, then I want to save the changes and I don't know how.
The second problem is:
void dbWindow::add_changes_kraj() {
QSqlQuery query;
QString table_name = "kraj";
//we use NULL because this is not php, and it will auto increment on it's own
query.prepare("INSERT INTO :table (id,ime,postna_st) VALUES(NULL,:ime,:postna_st)");
query.bindValue(":table",table_name);
query.bindValue(":ime",edit_ime->text());
query.bindValue(":postna_st",edit_postna_st->text());
query.exec();
//query.exec("insert into kraj values(NULL,'Town','4532')");
emit close();
}
- what is commented (query.exec("insert into kraj values(NULL,'Postojna','4532')");) works perfectly, but the other lines don't (which is the same...and I need to make them work).
Any idea?