Results 1 to 20 of 21

Thread: connecting to MySQL through it's API

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2006
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Question connecting to MySQL through it's API

    I'm now trying to connect to my app to MySQL using mysql.h from MySQL 4.1.... as I just can't make the damn plugin... somewhere theres a post explaining the plugin stuff..

    The thing now is that after I made the connection I retrieve the table list as this:

    Qt Code:
    1. .......
    2. #include <mysql.h>
    3. ....
    4. ..
    5. MYSQL_RES *res;
    6. ...
    7. ..
    8.  
    9. QStringList tablas()
    10. {
    11. if (!res=mysql_list_tables( &mysql, NULL ))
    12. {
    13. QMessageBox::warning(0,"No se pudo obtener la lista de tablas", mysql_error( &mysql ));
    14. }
    15. QStringList listaTablas = res->toStringList;
    16. //convert MYSQL_RES to QSTRINGLIST ???
    17. for ( QStringList::Iterator it = listaTablas.begin(); it != listaTablas.end(); ++it ) {
    18. qWarning(*it + "\n");
    19. }
    20. //muestra en consola la lista de tablas de la base de datos a la que se conecto
    21.  
    22. return listaTablas;
    23. }
    To copy to clipboard, switch view to plain text mode 

    so the question is..... tararraaarrataaan.
    how do i get res to fill a QStringList?

    I've tryed casting:
    Qt Code:
    1. QStringList listaTablas = (QStringList)res;
    To copy to clipboard, switch view to plain text mode 

    Dumbass way:
    Qt Code:
    1. QStringList listaTablas = res;
    To copy to clipboard, switch view to plain text mode 

    and DumbAss2 xD as there is no member... etc
    error: 'struct st_mysql_res' has no member named 'toStringList
    Qt Code:
    1. QStringList listaTablas = res->toStringList;
    To copy to clipboard, switch view to plain text mode 


    Any ideas?
    the final idea is to fill a qcombobox with the QStringList with the table list

    Qt Code:
    1. CB_Tablas->insertStringList(tablas());
    To copy to clipboard, switch view to plain text mode 

    as you can see the function named tablas returns a QStringList that contains or should contain the table list from the database

    please don't tellme to use qdatabase.h as that's now not an option
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: connecting to MySQL through it's API

    You have to process the result row by row and extract the data yourself... You can take a look at QMYSQL plugin to see how it does it. Oh, and don't give up compiling that plugin To be honest I have never had problems with that... Maybe you should try one more time? You can take a look ath the FAQ, maybe it'll help you.

  3. #3
    Join Date
    Apr 2006
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Talking Re: connecting to MySQL through it's API

    jajja I finally made de damn plugin but I'm still geting ths Driver not Loaded shh..
    I'm now running:
    Qt Code:
    1. configure -plugin-sql-mysql -I d:\mysql\include -L d:\mysql\lib\opt
    To copy to clipboard, switch view to plain text mode 

    if that doesn't work... I finnished with the damn plugin...

    And I'm looking to the code on the main.cpp from the mysql plugin and nothing so I'm looking on the qsql_mysql.cpp and well no ideas yet

    ... jejejej wait a second I think I got the idea xD... :$ as you can tell i'm working on real time XD

    I realy hope the plugin work.... I would like to keep it qt and not doing a mixed ..... thing..
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: connecting to MySQL through it's API

    Do you use Qt3 or Qt4?

  5. #5
    Join Date
    Apr 2006
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Unhappy Re: connecting to MySQL through it's API

    on this case. I'm working on Qt 4.1.2 as I need to make the plugin for an app which needs to run on windows... so everything I made on linux and works with the Qt 3.1.2 on linux has to run on wnidows compiled and ported to Qt 4.1.2 the ap and the porting works perfectly.. I just have to modify de conection... change the pointer for a variable.. changing the '->' for '.' etc.. and I have to add the #include <qsqlerror.h> but it works without problems excepet for the "Driver not Loaded"...
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    it works without problems excepet for the "Driver not Loaded"...
    Check with Dependency Walker if your application and the plugin can find all DLLs they need. If there is a missing DLL, find it and place in the same directory as the executable.

  7. #7
    Join Date
    Apr 2006
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Default Re: connecting to MySQL through it's API

    I ran DependencyWalker on my app's exe and it tells me that couldn't find MSJAVA.DLL

    java?
    I don't remember have used java so... ?

    but well..
    on the other side.. I'm now worried about how to populate a qdatatable using the MySQL API ... mysql.h etc etc
    I made a conection and populated a qcombobox with the tables from the database..
    so now I'm trying to populate a qdatatable with the qsqlcursor... but I guess I'm not able to use it as the connection is made through the MySQL API not by qt.
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    I ran DependencyWalker on my app's exe and it tells me that couldn't find MSJAVA.DLL
    You can safely ignore msjava.dll. Are there any other missing DLLs (especially for the plugin)?

  9. #9
    Join Date
    Apr 2006
    Posts
    40
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    12

    Angry Re: connecting to MySQL through it's API

    it tells me that the libmysql.dll is missing so I putted it on the same folder as the exe and the qsqlmysql.dll and there's still Driver not Loaded message

    and the other way using a MySQL API connection works on linux but on windows at compilling time... it just tells me errors on mysql_com.h and that a SOCKET is created without a type

    ¬¬ Qt hates me...
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: connecting to MySQL through it's API

    Quote Originally Posted by Philip_Anselmo
    it tells me that the libmysql.dll is missing so I putted it on the same folder as the exe and the qsqlmysql.dll and there's still Driver not Loaded message
    Do I understand you correctly that you have placed the plugin and the executable in the same directory?

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: connecting to MySQL through it's API

    qsqlmysql.dll should be in "sqldrivers/" subdirectory.

Similar Threads

  1. Replies: 1
    Last Post: 21st March 2006, 12:54
  2. mySql Result Datatype issues!!!
    By bera82 in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2006, 10:26
  3. issues compiling Qt4.1 with mysql
    By patcito in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2006, 22:41
  4. Error connecting to MySQL
    By probine in forum Qt Programming
    Replies: 20
    Last Post: 23rd February 2006, 23:13
  5. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 20:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.