Hi,
db.setDatabaseName(name);
db.setHostName(host);
if(!db.open(user,pass)){
return -1;
}
query.exec(_query);
QString result
= query.
result();
//How do i do this part db.close();
return result;
}
QString QueryDatabase(QString _query){
QSqlDatabase db = QSqlDatabase::addDatabase(type); //Available Types QMYSQL, QPSQL and QSQLITE
db.setDatabaseName(name);
db.setHostName(host);
if(!db.open(user,pass)){
return -1;
}
QSqlQuery query;
query.exec(_query);
QString result = query.result(); //How do i do this part
db.close();
return result;
}
To copy to clipboard, switch view to plain text mode
I want to query the database with string like "select count(*)....." and the return value will always be in one row as its just counting the number of occurances.. how can i get the result direct of the row to QString??
Thanks
Bookmarks