title: DataBase Connection QSqlQuery::exec: database not open
body: <p>I'am having a problem with my database when i execute the project it shows this error:</p>
  
  <pre><code>QSqlQuery::exec: database not open 
  </code></pre>
  
  <p>this is my connexion</p>
  
  <pre><code>#include "connexion.h"
  #include &lt;QSqlError&gt;
  
  bool connexion::CreatConnexion()
  {
      QSqlDatabase mydb;
     mydb = QSqlDatabase::addDatabase("QODBC") ;
  
     mydb.setDatabaseName("prosit");
     mydb.setUserName("DD");
     mydb.setPassword("DDDD");
  
  bool test;
     if(mydb.open())
     {if (mydb.open())
             test=true;
  
         else throw QString ("Erreur Paramétres"+mydb.lastError().text());
         return  test;
  
  }
  }
  </code></pre>