Changing SQL Value
-
Hi,
IIRC the SQL examples uses in memory databases so there are no files there.
Look at connection.h in the sql example folder
Hope it helps
-
Do you have example.sqlite in the same folder as your executable ?
You have two options:
- copy your example.sqlite in the same folder as your executable
- give the complete path when calling setDatabaseName
-
@static bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("t_job.sqlite");
if (!db.open()) {
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
"to build it.\n\n"
"Click Cancel to exit."), QMessageBox::Cancel);
return false;
}QSqlQuery query; query.exec("create table examp (id int primary key, " "firstname varchar(20), lastname varchar(20))"); query.exec("insert into examp values(1, 'Ordem1.zip', '10:20')"); query.exec("insert into examp values(2, 'Text', '12:00')"); query.exec("insert into examp values(3, 'Low', '9:00')"); query.exec("insert into examp values(1, 'c:wampfolder', '10:00')"); query.exec("insert into examp values(2, '10.32.1.1Text', '11:00')"); return true;
}@
I have all files in the right location but...
I think my problem may be here:@TableEditor::TableEditor(const QString &myexample, QWidget *parent)
: QWidget(parent)
{
model = new QSqlTableModel(this);
//model->setTable(tableName);
model->setTable(myexample);...
@ -
What does myexample contain ?
-
I meant what is the myexample variable value ?
-
I think I didn't understand the question... variable values?
myexample is a table like this
ID | username | email | status
1 | pemo | pemo@mail.com | 1
2 | pe | pe@mail.com | 0
3 | pemoam | pemoam@mail.com | 1
4 | user | user@mail.com | 0
5 | newuser | newuser@mail.com | 1
5 | username | username@mail.com | 1 -
In your TableEditor constructor, you have the myexample parameter, what does it contain ?