I am using this SELECT name FROM sqlite_master WHERE type = "table" AND name = 'create_organization'; to check if the table named create_organization exists and it works.However i would like to use qt to find that out.I am trying
QSqlQuery query;
QString tableName = "employee_datastores";
QString sqlQuery = QString("SELECT name FROM sqlite_master WHERE type =:table AND name = %1 ").arg(tableName);
query.prepare(sqlQuery);
query.bindValue(":table", "table");
query.exec();
int fieldNo = query.record().indexOf("employee_datastore_name");
while (query.next()) {
QString employee_ds_name = query.value(fieldNo).toString();
qDebug() << "Table Name" << employee_ds_name ;
}
but it does not work.
Does QSqlDatabase::tables() give you what you want? For example you could try: