title: SQLDataBase setDatabaseName doesn't work in QT
body: <p>I have two method in one class that contain these code, In method GetDefinitionOfWord, at first i've been call GetDictionaryFilePath that correctly return the name of DB, but in method GetDefinitionOfWord when execute db.setDatabaseName(GetDictionaryFilePath(ID));</p>
  
  <p>It doesn't set the database name and can't open DB and i'll get error, how can i fix this?</p>
  
  <p>Please help me</p>
  
  <pre><code>    QString Dictionary_Operation::GetDefinitionOfWord(QString ID, QString Word)
      {
          QString Result = "";
          QString FinalResult = "";
          QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
  
          QString DBOpenErrorTitle = QString::fromStdString("Error");
          QString DBOpenErrorMessage = QString::fromStdString("Access denied.");
  
  
          QString FileName = GetDictionaryFilePath(ID);
  
              db.setDatabaseName(GetDictionaryFilePath(ID));
  
          if (QFile::exists(QString::fromStdString(".\\" + FileName.toStdString()))) {
                      db.setDatabaseName(GetDictionaryFilePath(ID));
                      if (!db.open()) {
                          QMessageBox::critical(0, DBOpenErrorTitle, DBOpenErrorMessage,
                                  QMessageBox::Cancel);
  
                      }
                      else
                      {
  
               QSqlQuery query;
              query.exec(QString::fromStdString("PRAGMA encoding = UTF-16"));
  
              QString s = QString::fromStdString("SELECT Definition FROM Dictionary_Words WHERE HeadWord = '%1'").arg(ID);
             QSqlQuery sql(s, db);
              while ( sql.next() )
              {
                    Result =  Result.append(sql.record().value(0).toString());
              }
  
              db.close();
                  FinalResult = ReplaceImageToBase64(Result, ID);
              }
          }
          QSqlDatabase::removeDatabase(FileName);
  
          return FinalResult;
      }
  </code></pre>
  
  <p>and Other method is:</p>
  
  <pre><code>      QString Dictionary_Operation::GetDictionaryFilePath(QString ID)
          {
              QString Result = "0";
              QSqlDatabase dbGetDictionaryFilePath =  QSqlDatabase::addDatabase("QSQLITE");
  
              QString DBOpenErrorTitle = QString::fromStdString("Error");
              QString DBOpenErrorMessage = QString::fromStdString("Access denied.");
  
  
              if (QFile::exists(".\\1.pldb")) {
                          dbGetDictionaryFilePath.setDatabaseName(QString::fromStdString("1.pldb"));
                          if (!dbGetDictionaryFilePath.open()) {
                              QMessageBox::critical(0, DBOpenErrorTitle, DBOpenErrorMessage,
                                      QMessageBox::Cancel);
  
                          }
                          else
                          {
  
                   QSqlQuery query;
                  query.exec(QString::fromStdString("PRAGMA encoding = UTF-16"));
  
  
                  QString s = QString::fromStdString("SELECT FileName FROM Dictionaries WHERE ID = %1").arg(ID);
                 QSqlQuery sql(s, dbGetDictionaryFilePath);
                  while ( sql.next() )
                  {
                        Result =  sql.record().value(0).toString();
                  }
  
                 // dbGetDictionaryFilePath.close();
  
                  }
              }
              QSqlDatabase::removeDatabase(QString::fromStdString("1.pldb"));
  
              return Result;
          }
  </code></pre>