Results 1 to 7 of 7

Thread: QT MySQL

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT MySQL

    Hi,
    Thakyou for your reply, I had take a new project, after that i had add three LineEdit control and three pushbuttons. After that i write the code for working that. then it is worked. After that i wish to insert that values into a table ( MYSQL ). Then i get into the net and get the code. I paste that code in main.cpp and give the command for make.
    I had replace the special character ( ie, ->, , et ). After this i give the command " qmake -o Makefile mark.pro " then there is no error display.
    But after that i give the command "make" then the error message is display
    The code is
    =================================
    QsqlDatabase *defaultDB=QsqlDatabase::addDatabase("QMYSQL3");
    defaultDB->setDatabaseName("test");
    defaultDB->setPassword("");
    defaultDB->setHostName("localhost");
    if(defaultDB->open())
    {
    qWarning("Database connection successful");
    }
    else
    {
    qWarning("Database connection failed");
    return a.exec();
    }

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

    The error is
    ==============================
    g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
    main.cpp:6:28: error: connection.h: No such file or directory
    .ui/FarkData.h:47: error: ISO C++ forbids declaration of ‘QSqlDatabase’ with no type
    /usr/lib/qt-3.3/include/qsqldatabase.h:63: warning: ‘class QSqlDriverCreatorBase’ has virtual functions but non-virtual destructor
    main.cpp: In function ‘int main(int, char**)’:
    main.cpp:12: error: ‘QsqlDatabase’ was not declared in this scope
    main.cpp:12: error: ‘defaultDB’ was not declared in this scope
    main.cpp:12: error: ‘QsqlDatabase’ is not a class or namespace
    main.cpp:12: error: ‘addDatabase’ was not declared in this scope
    make: *** [.obj/main.o] Error 1
    ================================================== =====


    After this I try for another code and get a new one, that is

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

    QSqlDatabase *defaultDB = QSqlDatabase::addDatabase( "QMYSQL" );
    defaultDB->setDatabaseName( "test" );
    defaultDB->setUserName( "root" );
    defaultDB->setPassword( "" );
    defaultDB->setHostName( "localhost");

    if ( defaultDB->open() ) {
    printf("Sucessfully Connected \n");
    // Database successfully opened; we can now issue SQL commands.
    }

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

    then i give the command
    qmake -o Makefile mark.pro
    no error display... When i give the command
    make

    then the following error display...
    ====================================
    /usr/lib/qt-3.3/bin/uic FarkData.ui -o .ui/FarkData.h
    g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
    main.cpp:6:28: error: connection.h: No such file or directory
    .ui/FarkData.h:47: error: ISO C++ forbids declaration of ‘QSqlDatabase’ with no type
    /usr/lib/qt-3.3/include/qsqldatabase.h:63: warning: ‘class QSqlDriverCreatorBase’ has virtual functions but non-virtual destructor
    make: *** [.obj/main.o] Error 1
    ==================================

    please help me sir....
    thankyou...
    Sabeesh
    Last edited by sabeeshcs; 10th January 2007 at 12:52.

Similar Threads

  1. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 10:19
  2. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 13:48
  3. MYSQL Triggers??
    By allensr in forum General Programming
    Replies: 1
    Last Post: 2nd October 2006, 22: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, 14: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.