Hello !

I'm trying to use QSqlDataBase with the QSQLITE plugin, but I have a DRIVER NOT LOADED error.

The QSql4.dll is at the root of my soft (a DLL projetc) and I have also create the sqldrivers folder and put the qslite.dll inside.

arbo.jpg

this is my entire class :

SDManagerDataBase.h :

Qt Code:
  1. #ifndef SDMANAGERDATABASE_H
  2. #define SDMANAGERDATABASE_H
  3.  
  4. #include <QObject>
  5. #include <QSqlDataBase>
  6. #include <QSqlQuery>
  7. #include <QVariant>
  8. #include <QSqlError>
  9. #include "SDManagerPreset.h"
  10.  
  11. #include <iostream>
  12. #include <string>
  13. #include <fstream>
  14.  
  15. using namespace std;
  16.  
  17. class SDManagerDataBase : public QObject
  18. {
  19. Q_OBJECT
  20.  
  21. public:
  22. SDManagerDataBase(QObject *parent = 0);
  23. ~SDManagerDataBase();
  24.  
  25. int findPresetAssociationByTitle(QString title);
  26. bool getPresetById(int id, SDManagerPreset* &preset);
  27.  
  28. public:
  29.  
  30. private:
  31. };
  32.  
  33. #endif // SDMANAGERDATABASE_H
To copy to clipboard, switch view to plain text mode 

SDManagerDataBase.cpp :

Qt Code:
  1. #include "SDManagerDataBase.h"
  2.  
  3. SDManagerDataBase::SDManagerDataBase(QObject *parent)
  4. : QObject(parent)
  5. {
  6. db = QSqlDatabase::addDatabase("QSQLITE");
  7. db.setDatabaseName("E:/FSX/Modules/SDManager/SDManager.s3db");
  8. db.open();
  9. }
  10.  
  11. SDManagerDataBase::~SDManagerDataBase()
  12. {
  13.  
  14. }
  15.  
  16. int SDManagerDataBase::findPresetAssociationByTitle(QString title)
  17. {
  18. int lretour = -1;
  19.  
  20. QString sql = "select preset_id from sdsm_presets_associations "
  21. "where association_aircraftname = :title";
  22. QSqlQuery query;
  23. query.prepare(sql);
  24. query.bindValue(":title", title);
  25. query.exec();
  26.  
  27. if (query.next())
  28. {
  29. lretour = query.value(0).toInt();
  30. }
  31.  
  32. return lretour;
  33. }
  34.  
  35. bool SDManagerDataBase::getPresetById(int id, SDManagerPreset* &preset)
  36. {
  37. QString sql = "select P.*, S.* from sdsm_presets_stations S, sdsm_presets_list P"
  38. "where S.preset_id=P.preset_id AND P.preset_id = :id";
  39. QSqlQuery query;
  40. query.prepare(sql);
  41. query.bindValue(":id", id);
  42. query.exec();
  43.  
  44. if (query.next())
  45. {
  46. preset->gPresetId = query.value(0).toInt();
  47. preset->gPresetName = query.value(3).toString();
  48.  
  49. SDManagerStation lStation = SDManagerStation(query.value(2).toInt(), query.value(3).toString(), query.value(4).toInt(), query.value(5).toInt());
  50.  
  51. preset->gPresetStations->append(lStation);
  52. }
  53.  
  54. return query.size() != -1;
  55. }
To copy to clipboard, switch view to plain text mode 

This is how a create my SDManagerDataBase object to open a connection :

Qt Code:
  1. dB = new SDManagerDataBase();
To copy to clipboard, switch view to plain text mode 

If someone can help me ?

Thank you in advance.