Qt Code:
  1. bool crearTablas(QWidget *parent){
  2. QSqlQuery query("CREATE TABLE itinerario(id INTEGER, nombre VARCHAR(32), tipo_sendero INTEGER, "
  3. "municipio VARCHAR(25), fecha_visita DATE, punto_salida VARCHAR(25), punto_llegada VARCHAR(25), "
  4. "zona VARCHAR(25), provincia VARCHAR(25), fecha DATE, mapa VARCHAR(25), modo_realizacion INTEGER);");
  5.  
  6. if(!query.exec()){
  7. QMessageBox::critical(parent, "", query.lastError().text());
  8.  
  9. return false;
  10. }
  11. return true;
  12. }
To copy to clipboard, switch view to plain text mode 

Is this code wrong? I'm trying to query a database created in another function and it gives the error:
SQL logic error or missing database Unable to fetch row
But if I redo the query the error changes to:
table itinerario already exists Unable to fetch
Any help?