Results 1 to 20 of 23

Thread: Connectingto MySQL with QODBC3

Hybrid View

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

    Default Re: Connectingto MySQL with QODBC3

    Quote Originally Posted by Philip_Anselmo
    I've tryed with QMySQL3 and it works perfectly, but i'm not able to use the qmysql on windows
    Why not?
    so I can't use it now because I need to work with the same code on Linux Qt 3.1.2 and windows Qt 4.1.2-3
    You won't be, because Qt3 and Qt4 database interfaces differ (for example addDatabase of one of them returns a pointer and in the other -- an object).

    My question is.. once I made the connection with odbc, the workaround with qsqlcursor is the same as with qmysql3?
    The general idea of using Qt database abstraction is that it is abstract -- it doesn't depend on the driver used. You should be able to use ODBC and MYSQL drivers using the same code. The only line which differs will be the one which chooses the driver type, but you can work it around using #ifdef-#endif constructions.

  2. The following user says thank you to wysota for this useful post:

    Philip_Anselmo (7th June 2006)

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

    Unhappy Re: Connectingto MySQL with QODBC3

    I know the diference on qt3 and 4 with the pointer on the database connection

    the problem on using qmysql on windows... well at this time I just think it's imposible... at least everything I've tryed didn't work I just give up on that.. if you search all my posts here I think you'll find out that 4/5 of them are about the qmysql pluginI even made a how-to about it and it worked for others but not here on 3 windows!!! Qt hates me

    I just hope ODBC works... if not.. well.. no more qt+mysql for me


    by the way I think it isn't connecting:

    Qt Code:
    1. QSqlDatabase *defaultDB;
    2. bool creaConexion()
    3. {
    4. defaultDB = QSqlDatabase::addDatabase( DBDRIVER );
    5. if (defaultDB!=0)
    6. {
    7. defaultDB->setHostName( DB_HOSTNAME );
    8. qWarning("host seteado");
    9. defaultDB->setDatabaseName( "Driver={MySQL};Server="+DB_HOSTNAME+";Database="+DB_NOM+";Uid="+DB_USR+";Pwd="+DB_PASS+";" );
    10. defaultDB->setUserName( DB_USR );
    11. defaultDB->setPassword( DB_PASS );
    12.  
    13. if ( ! defaultDB->open() )
    14. {
    15. QMessageBox::warning(0, "Fallo de conexión", "No se pudo conectar con la base de datos: " + DB_NOM + "tabla: " + DB_TABLA + "\n" + defaultDB->lastError().driverText());
    16. return FALSE;
    17. }
    18. QMessageBox::information(0,"Conexión estabecida","Conectado a: " + DB_HOSTNAME + " " + "tabla: " + DB_TABLA + " "+ DB_NOM);
    19. qWarning("No pesko");
    20. return TRUE;
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 
    the qWarning tells me:
    QODBC3: Unable to connect
    and on console:
    QODBCDriver::disconnect: Unable to disconnect datasource Error: [unixODBC][Driver Manager]Connnection does not exist
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

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

    Default Re: Connectingto MySQL with QODBC3

    Quote Originally Posted by Philip_Anselmo
    the problem on using qmysql on windows... well at this time I just think it's imposible... at least everything I've tryed didn't work I just give up on that.. if you search all my posts here I think you'll find out that 4/5 of them are about the qmysql pluginI even made a how-to about it and it worked for others but not here on 3 windows!!! Qt hates me
    You're probably making the same mistake all the time. But doesn't Qt for Windows come with a precompiled binary mysql driver? Or maybe you could ask someone else to compile the driver for you? There is really no reason to reinvent the wheel...

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

    Default Re: Connectingto MySQL with QODBC3

    I-ve done that
    but even when the plugin is present it tells me driver not loaded
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

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

    Default Re: Connectingto MySQL with QODBC3

    Did you check its dependencies? Among other, it depends on mysqlclient library... It has to be available and has to be found by the plugin.

  7. The following user says thank you to wysota for this useful post:

    Philip_Anselmo (8th June 2006)

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

    Talking Re: Connectingto MySQL with QODBC3

    yeap I checked that too
    and it also depends on MSJAVA.dll but it weren't available
    but I've never even thought about using java on neither one of the 2 pcs where i've compiled and made my app, and according to JaCek and I belived him that, that's not the problem

    but well about the ODBC? any ideas? anyone else read this?
    I don't want to bother you too much wysota

    can anyone post an example code of a connection to mysql through ODBC that fills a datatable or some structure like that or simplily uses a cursor? Please

    I uploaded my proyect so you could dowload it from this address
    Last edited by Philip_Anselmo; 8th June 2006 at 15:33.
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

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

    Default Re: Connectingto MySQL with QODBC3

    You're not bothering me, don't worry.

    Which version of mysql do you use anyway?

    BTW. I don't know if MySQL through ODBC supports cursors...

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

    Red face Re: Connectingto MySQL with QODBC3

    I'm using mysql Ver 11.18 Distrib 3.23.58, for redhat-linux-gnu (i386), Qt 3.1.2,Fedora Core 1,ODBC 2.2.8, MyODBC-2.50.39-17, g++ (GCC) 3.3.2 20031022

    here you can see a log of my app's strace
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

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

    Default Re: Connectingto MySQL with QODBC3

    I'm starting to be getting lost... Last time you were talking about Qt4 and Windows, now about Qt3 and Linux... Could you make up your mind? Which driver can't you enable?

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

    Red face Re: Connectingto MySQL with QODBC3

    jajaja

    I'm programming on the fedora everything is made here on the fedora, the qmysql3 pluging works perfect here on Linux but not on windows with qt4 and I have to make it so it works on both Linux Qt 3.1.2 and windows Qt 4.1.2
    on windows I can't make the plugin to work.. it compiles some times but it still tells me driver not loaded so the qmysql3 is out of the question because it works only on linux
    now the odbc isn't working here on the linux so I haven't tested it yet on windows
    the most important right now is that it has to work on windows, because the final users will, the most of the time (not to say always), work on windows. Personaly I prefer Linux to work and wintendo as a game console and the office, but that's me.
    So I have to make it work on windows.
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

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

    Default Re: Connectingto MySQL with QODBC3

    Quote Originally Posted by Philip_Anselmo
    I'm programming on the fedora everything is made here on the fedora, the qmysql3 pluging works perfect here on Linux but not on windows with qt4 and I have to make it so it works on both Linux Qt 3.1.2 and windows Qt 4.1.2
    So maybe it's better to switch to Qt4 on Linux too? Why develop two apps instead of one?

    on windows I can't make the plugin to work.. it compiles some times but it still tells me driver not loaded
    Maybe it can't find some required component? Like the mysql library I already mentioned.

    so the qmysql3 is out of the question because it works only on linux
    So what? Use qmysql on Linux and qodbc on Windows... Who said you have to use the same driver?

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

    Red face Re: Connectingto MySQL with QODBC3

    I can't install qt 4.1.2 here because of some libraries.. fedora core 1......

    the libmysqlclient is present when i compile

    and well the lastone.. i don't know maybe I just could do that but that depends on my boss's opinion..
    and the 1º one also depends on my boss xD
    if I could I would use Debian Sarge...
    I need a notebook
    I just wish I had an Alienware

    so any ideas about this?:

    QODBCDriver::disconnect: Unable to disconnect datasource Error: [unixODBC][Driver Manager]Connnection does not exist
    I just founded a post on qtforum that someone has the same problem.. but on that forum none ever answers
    Battle Programmer Ph1L
    Philip_Anselmo
    Greetings From Osorno - Chile

Similar Threads

  1. Embedded Mysql Windows Qt4.1
    By benguela in forum Qt Programming
    Replies: 7
    Last Post: 17th January 2007, 00:13
  2. connecting to MySQL through it's API
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 20
    Last Post: 30th May 2006, 23:22
  3. Replies: 1
    Last Post: 21st March 2006, 12:54
  4. mySql Result Datatype issues!!!
    By bera82 in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2006, 10:26
  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.