PDA

View Full Version : Failed to execute “SHOW CREATE TABLE” query in Qt



alizadeh91
4th May 2014, 10:41
Suppose I have a table called 'logs' in mysql and I want to get the create query of this table in Qt(5.2 mingw). Here is what I have done so far:


QSqlQuery query(connection);

query.prepare("SHOW CREATE TABLE logs");
if(query.exec())
{
if(query.next())
query.value(1).toString();
}
After executing the code, the query.exec() returns true but the query.next() returns false. This query executes successfully in the mysql client(navicat) so I'm pretty sure about the query.

Note that QSqlQuery::lastError() gives -1 means no error!

I'll appreciate for any guidance or help.