ksqt
11th September 2006, 02:27
I cannot seem to return text from a record in a table..:confused:
In this function - "bg_word" is a text string in a record in a table.
I can return an integer if I make the necessary changes, but not text...
What am I missing?
(Yes, there is warnings of not using the two bools - not important at this point)
void Dialog::translate()
{
QString bg;
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("");
db.setDatabaseName("enbg_database");
db.setUserName("");
db.setPassword("");
bool ok = db.open();
QSqlQuery query;
bool queryok = query.exec("select bg_word from enbg_table where id=1");
while(query.next())
{
bg = query.value(0).toString();
}
translated_bg->setText(bg);
}
In this function - "bg_word" is a text string in a record in a table.
I can return an integer if I make the necessary changes, but not text...
What am I missing?
(Yes, there is warnings of not using the two bools - not important at this point)
void Dialog::translate()
{
QString bg;
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("");
db.setDatabaseName("enbg_database");
db.setUserName("");
db.setPassword("");
bool ok = db.open();
QSqlQuery query;
bool queryok = query.exec("select bg_word from enbg_table where id=1");
while(query.next())
{
bg = query.value(0).toString();
}
translated_bg->setText(bg);
}