QtSQL - Where is My Database?
Hello There.
I Have an Database from 1Blue, with the table "test"
now i Can connect without problems, but db.tables() says that there are no tables. Why?
My Code (Zensored)
Code:
db.setHostName("mysql12.1blu.de");
db.setDatabaseName("***********");
db.setUserName("**********");
db.setPassword("**********");
bool ok = db.open();
qDebug() << db.tables();
qDebug() << db.isValid();
qDebug() << db.isOpen();
And the Return:
()
true
true
So why there are no tables? In phpMyAdmin there are tables!
I hope someone can help me.
MFG feuerball11
PS: Sorry for bad english
Re: QtSQL - Where is My Database?
You're using a wrong driver. If you want to connect to a MySQL database, use QMYSQL driver instead of QSQLITE.
Re: QtSQL - Where is My Database?
Then its not Working. The Programm returns:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
()
false
false
Re: QtSQL - Where is My Database?
Then you need to install the driver or its dependencies.
Re: QtSQL - Where is My Database?
Sry for the noob question, but where can i get this driver? must everone install this driver how uses my programm, or only i to compile it?
Re: QtSQL - Where is My Database?
Check if you have the plugin library available. If yes, then probably all you need is to install MySQL client libraries. If no, you'll need to build the plugin
Re: QtSQL - Where is My Database?
If you are using the Qt SDK then you might find this [WIKI]Building the Database Plugins for QtSDK Users[/WIKI] wiki page useful in conjunction with the docs that wysota linked to.
You will not need to compile the plugin for every user but you will need to deploy the plugin and the MySQL client libraries with your software.
Re: QtSQL - Where is My Database?
AT first. I Using Visual Studio 2008
I compiled the plugin again and again. but its not working.
i put qsqlmysqld4.dll and qsqlmysqld4.lib into the folder
C:\Qt\4.8.2\plugins\sqldrivers
but qt says only:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
can anyone helb me? it cant be so difficult to run this plugin -.-
Re: QtSQL - Where is My Database?
You do not have to manually copy anything to install the plugin:
does that for you.
The MySQL runtime libraries must be available in the environment (i.e. PATH) of the running program in order to load the plugin.
Re: QtSQL - Where is My Database?
nmake install was sucsesfull, but it doesent work again...
"Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" geladen, Symbole wurden geladen.
"Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" entladen.
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
.... this is anoying ...
Re: QtSQL - Where is My Database?
Quote:
The MySQL runtime libraries must be available in the environment (i.e. PATH) of the running program in order to load the plugin.
It might be annoying, but you already have the answer. Just like any other piece of code, the Qt MySQL plugin cannot load if it cannot find the libraries it depends on. These libraries are part of MySQL and nothing to do with Qt itself. Windows has a well documented search mechanism for locating dynamically loaded libraries.
On your development machine you can simply place the MySQL bin directory into the system PATH or the PATH used by your IDE to run the software. (Just like the PostgreSQL libraries must be).
Re: QtSQL - Where is My Database?
Ok Thanks. It works. Didnt understand the sentence (bad english) but now i understand.
Realy big Thanks :-)
*edit*
ok little problem.. It runs in Debug, but not in release? why that? must i put dll files to the release?
Re: QtSQL - Where is My Database?
Did you build the plugin in release mode?
Re: QtSQL - Where is My Database?
I found it by myself.. now is the problem:
i can build a release version, it runs fine on my pc. but not on other pcs... it starts, but do not connect.
i added many dlls. but nothing helped.
addded this dlls to the exe:
libmysql.dll
qsqlmysql4.dll
qtcore4.dll
qtcored4.dll
gtgui4.dll
qtguid4.dll
qtsql4.dll
qtsqld4.dll
but with all this dlls, it wont connect to the database -.- and i have no way to see the debug log on other pcs with a compiled exe....
but on my pc it works from all destinations...
Re: QtSQL - Where is My Database?
Does QSqlDatabase::lastError() return any meaningful information?
Re: QtSQL - Where is My Database?
Quote:
Originally Posted by
feuerball11
i can build a release version, it runs fine on my pc. but not on other pcs... it starts, but do not connect.
i added many dlls. but nothing helped.
addded this dlls to the exe:
libmysql.dll
qsqlmysql4.dll
qtcore4.dll
qtcored4.dll
gtgui4.dll
qtguid4.dll
qtsql4.dll
qtsqld4.dll
but with all this dlls, it wont connect to the database -.- and i have no way to see the debug log on other pcs with a compiled exe....
but on my pc it works from all destinations...
The qsqlmysql4.dll file should be placed into a subfolder "sqldrivers" next to the program executable. You may need to place libmysql.dll with it (I am not sure).
You do not need to deploy the debug version of the Qt libraries, qtcored4.dll, qtguid4.dll, or qtsqld4.dll, for a release application. Should look like:
Code:
C:\Program Files\MyApp\
MyApp.exe
qtcore4.dll
gtgui4.dll
qtsql4.dll
sqldrivers\
qsqlmysql4.dll
libmysql.dll // possibly here, possibly in directory above
imageformats\
...
codecs\
...
iconengines\
...
Re: QtSQL - Where is My Database?
now it finaly works. thanks. i worked yesterday the hole day on this ****** problem.....
EPIC THX ^^
Re: QtSQL - Where is My Database?
And enough to read the documentation. In particular this.
Re: QtSQL - Where is My Database?
Quote:
Originally Posted by
feuerball11
nmake install was sucsesfull, but it doesent work again...
"Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" geladen, Symbole wurden geladen.
"Testumgebung.exe": "C:\Qt\4.8.2\plugins\sqldrivers\qsqlmysqld4.dl l" entladen.
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
.... this is anoying ...
Sorry i don't read full thread but why are you not use QODBC driver? i use it with MySql and it work fine