Results 1 to 7 of 7

Thread: QT MySQL

Hybrid View

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

    Default Re: QT MySQL

    Did you #include <qsqldatabase.h>?

  2. #2
    Join Date
    Jan 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT MySQL

    Yes, I include these header files,

    #include <qapplication.h>
    #include "/usr/include/mysql/mysql.h"
    #include <qsqldatabase.h>
    #include <qsqlquery.h>

    ok i solve the problem.


    But now I had occure another one

    I wand to execute a query in QT.
    The following is the code...

    ================================================== ==
    double id, mark1, mark2, mark3, total;
    const char *name;
    name = TxtName->text();
    mark1 = TxtMark1->text().toDouble();
    mark2 = TxtMark2->text().toDouble();
    mark3 = TxtMark3->text().toDouble();
    id = TxtMark4->text().toDouble();

    total = mark1 +mark2+mark3;

    QSqlQuery target;

    QString sql = "insert into student ( s_id, s_name, s_mark1, s_mark2, s_mark3, s_total ) values( " ;

    ==================================================

    After this i am stuck!!!!!!!!!!!
    how can i add the values of the variables to that string ' sql ' ?

    please help me......

    sabeesh




    ================================================== ===






    Sabeesh
    Last edited by sabeeshcs; 11th January 2007 at 06:11.

  3. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QT MySQL

    Just example from docs...
    Qt Code:
    1. QSqlQuery query;
    2. query.prepare( "INSERT INTO atable (id, forename, surname) "
    3. "VALUES (:id, :forename, :surname)" );
    4. query.bindValue( ":id", 1001 );
    5. query.bindValue( ":forename", "Bart" );
    6. query.bindValue( ":surname", "Simpson" );
    7. query.exec();
    To copy to clipboard, switch view to plain text mode 

    p.s. Read this all !
    a life without programming is like an empty bottle

  4. #4
    Join Date
    Jan 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT MySQL

    Thankyou for your help...

    I wish to consentrate developing graphical application in QT. ie, I wish to create an object with the help of some messure. Can you give some documentation about that.

Similar Threads

  1. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 09:19
  2. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48
  3. MYSQL Triggers??
    By allensr in forum General Programming
    Replies: 1
    Last Post: 2nd October 2006, 21:54
  4. Qt 4.1.4 & Mysql 5 on Linux x64
    By bothapn in forum Installation and Deployment
    Replies: 7
    Last Post: 4th August 2006, 13:23

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.