Hi,

I'm having a lot of problems (Unhandled exception at 0x00b9b66d in UsersApp.exe: 0xC0000005: Access violation reading location 0xcdcd024d.) the second time I execute setQuery().

I tried with "clear()", before, but another similar error pops.


Qt Code:
  1. QString search = "SELECT sname, ssurname, sidcard, dtdob, id FROM users WHERE iaccesslevel=:iaccesslevel AND (id=:id0 OR id = :id1)";
  2.  
  3.  
  4. QSqlQuery myquery(*m_pI->m_pUsersDB->GetDBPtr());
  5. myquery.prepare(search);
  6. myquery.bindValue(":iaccesslevel", 1);
  7. myquery.bindValue(":id0", 14); //For instance, id = 14
  8. myquery.bindValue(":id1", 15);
  9. alumnosFiltrados.exec();
  10.  
  11.  
  12. m_pI->m_pQueryModel->setQuery(myquery);
  13. m_pI->m_pQueryModel->setHeaderData(0, Qt::Horizontal, tr("Nombre") );
  14. m_pI->m_pQueryModel->setHeaderData(1, Qt::Horizontal, tr("Apellidos") );
  15. m_pI->m_pQueryModel->setHeaderData(2, Qt::Horizontal, tr("NIF") );
  16. m_pI->m_pQueryModel->setHeaderData(3, Qt::Horizontal, tr("Fecha Nacimiento") );
  17. ui.my_tableView->setModel(m_pI->m_pQueryModel);
  18.  
  19.  
  20. ui. my_tableView->setColumnHidden(4, true);
To copy to clipboard, switch view to plain text mode 

the first time works perfectly... but when the code is called again it stops after "m_pI->m_pQueryModel->setQuery(myquery);"

how this could be? is the query "broken" somehow?

thanks!